1. 镜像下载
docker pull mysql:8.0.21
2. 创建目录
创建data,conf等目录,用于保存mysql的数据
3. 启动镜像
docker run -it -d --name mysql --net=host \
-v /var/application/mysql8/data:/var/lib/mysql \
-v /var/application/mysql8/mysql-files:/var/lib/mysql-files \
-v /var/application/mysql8/conf:/etc/mysql \
-e MYSQL_ROOT_PASSWORD=iflytek@123 \
-e TZ=Asia/Shanghai mysql:8.0.21 \
--lower_case_table_names=1
data: mysql数据
conf: 配置文件
mysql-file: 配置文件挂载到宿主机时,需要将该目录挂载,否则启动报错
4. 进入容器, 修改连接配置
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'test@123';
flush privileges;
标签:mysql8,application,conf,mysql,var,docker,安装
From: https://www.cnblogs.com/virgosnail/p/17130332.html