Docker中部署mysql数据库:
Docker中部署mysql数据库_BADAO_LIUMANG_QIZHI的博客-CSDN博客
上面安装过mysql5.7,下面介绍安装Mysql8。
注:
博客:
BADAO_LIUMANG_QIZHI的博客_CSDN博客
关注公众号
霸道的程序猿
获取编程相关电子书、教程推送与免费下载。
1、拉取镜像最新版
docker pull mysql:latest
2、创建映射目录并进行授权
mkdir -p /usr/mysql8/conf /usr/mysql8/data
chmod -R 755 /usr/mysql8/
3、创建配置文件
vim /usr/mysql8/conf/my.cnf
4、修改配置文件内容
[client] #socket = /usr/mysql8/mysqld.sock default-character-set = utf8mb4 [mysqld] #pid-file = /var/run/mysqld/mysqld.pid #socket = /var/run/mysqld/mysqld.sock #datadir = /var/lib/mysql8 #socket = /usr/mysql8/mysqld.sock #pid-file = /usr/mysql8/mysqld.pid datadir = /usr/mysql8/data character_set_server = utf8mb4 collation_server = utf8mb4_bin secure-file-priv= NULL # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # Custom config should go here !includedir /etc/mysql8/conf.d/
5、启动容器
docker run -d --name mysql8 -v /usr/mysql8/conf/my.cnf:/etc/mysql/my.cnf -v /usr/mysql8/data:/var/lib/mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql:latest
6、连接测试