docker run --name mysql56 -v /mnt/mysql56:/var/lib/mysql -v /mnt/mysql56confd:/etc/mysql/conf.d -p 3308:3306 -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.6
# 说明 映射到真机3308端口
# 数据文件存放在/mnt/mysql56下
# 配置文件映射到/mnt/mysql56confd 需要修改的配置在这个文件夹新建配置文件即可
docker run –name xx_mysql -v D:\mysql\xx\data:/var/lib/mysql -v D:\mysql\xx\conf.d:/etc/mysql/conf.d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 –restart always -d mysql:8
你可能想直知道conf.d文件夹默认是啥,其实基本啥也没有
root@705c5d2e3dfc:/etc/mysql/conf.d# ls -al
total 12
drwxr-xr-x 2 root root 62 Nov 21 01:23 .
drwxr-xr-x 4 root root 94 Nov 21 01:23 ..
-rw-r–r– 1 root root 43 Nov 21 01:23 docker.cnf
-rw-r–r– 1 root root 8 Jul 9 2016 mysql.cnf
-rw-r–r– 1 root root 55 Jul 9 2016 mysqldump.cnf
root@705c5d2e3dfc:/etc/mysql/conf.d# cat docker.cnf[mysqld]
skip-host-cache
skip-name-resolve
root@705c5d2e3dfc:/etc/mysql/conf.d# cat mysql.cnf[mysql]
root@705c5d2e3dfc:/etc/mysql/conf.d# cat mysqldump.cnf[mysqldump]
quick
quote-names
max_allowed_packet = 16M
root@705c5d2e3dfc:/etc/mysql/conf.d#