docker mysql 默认配置文件路径
- mysql:5.7.16 默认路径/etc/mysql/mysql.conf.d/mysqld.cnf
- mysql:8.0.23 默认路径/etc/mysql/my.cnf
启动一个样例容器
- docker run --name mysql-temp -p 3311:3306 -e MYSQL_ROOT_PASSWORD=root --rm -d mysql:5.7.16
复制代码 查看默认的配置文件
- root@LAPTOP-42HSF5M2:/mnt/d/wslwork/mysql# docker exec -it mysql-temp /bin/bash
- root@dc70e41c489b:/# cd /etc/mysql/
- root@dc70e41c489b:/etc/mysql# ls -al
- total 24
- drwxr-xr-x 1 root root 4096 Nov 8 2016 .
- drwxr-xr-x 1 root root 4096 Mar 14 13:37 ..
- drwxr-xr-x 1 root root 4096 Nov 8 2016 conf.d
- lrwxrwxrwx 1 root root 24 Nov 8 2016 my.cnf -> /etc/alternatives/my.cnf
- -rw-r--r-- 1 root root 1050 Sep 28 2016 my.cnf.fallback
- -rw-r--r-- 1 root root 796 Sep 28 2016 mysql.cnf
- drwxr-xr-x 1 root root 4096 Nov 8 2016 mysql.conf.d
- root@dc70e41c489b:/etc/mysql# ls -al /etc/mysql/mysql.conf.d/
- total 12
- drwxr-xr-x 1 root root 4096 Nov 8 2016 .
- drwxr-xr-x 1 root root 4096 Nov 8 2016 ..
- -rw-r--r-- 1 root root 1191 Nov 8 2016 mysqld.cnf
- root@dc70e41c489b:/etc/mysql#
复制代码 那么这么多个文件,那个才是在docker 环境下MySQL的配置文件呢???
- root@LAPTOP-42HSF5M2:/mnt/d/wslwork/mysql# docker logs mysql-temp
- Version: '5.7.16' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
- # 查看启动日志,看输出的生效配置
- root@LAPTOP-42HSF5M2:/mnt/d/wslwork/mysql# docker exec -it mysql-temp /bin/bash
- root@dc70e41c489b:/#
- root@dc70e41c489b:/#
- # 到目录下面去查看,可以发现正在生效的配置文件路径是【/etc/mysql/mysql.conf.d】下的
- root@dc70e41c489b:/# cat /etc/mysql/* | grep "/var/run/mysqld/mysqld.sock"
- cat: /etc/mysql/conf.d: Is a directory
- cat: /etc/mysql/mysql.conf.d: Is a directory
- root@dc70e41c489b:/# cat /etc/mysql/conf.d/* | grep "/var/run/mysqld/mysqld.sock"
- root@dc70e41c489b:/# cat /etc/mysql/mysql.conf.d/* | grep "/var/run/mysqld/mysqld.sock"
- socket = /var/run/mysqld/mysqld.sock
- root@dc70e41c489b:/#
复制代码 其他的版本也可以通过这种方式来查看,最终见效的配置文件.
- root@LAPTOP-42HSF5M2:/mnt/d/wslwork/mysql# docker run --name mysql-temp -p 3311:3306 -e MYSQL_ROOT_PASSWORD=root --rm -d mysql:8.0.23
- root@LAPTOP-42HSF5M2:/mnt/d/wslwork/mysql# docker exec -it mysql-temp /bin/bash
- root@e62094f4ff02:/# ls -al /etc/mysql/
- total 20
- drwxr-xr-x 1 root root 4096 Apr 10 2021 .
- drwxr-xr-x 1 root root 4096 Mar 14 13:49 ..
- drwxrwxr-x 1 root root 4096 Apr 10 2021 conf.d
- -rw-rw-r-- 1 root root 1080 Apr 10 2021 my.cnf
- -rw-r--r-- 1 root root 1469 Dec 11 2020 my.cnf.fallback
- root@e62094f4ff02:/# ls -al /etc/mysql/conf.d/
- total 16
- drwxrwxr-x 1 root root 4096 Apr 10 2021 .
- drwxr-xr-x 1 root root 4096 Apr 10 2021 ..
- -rw-rw-r-- 1 root root 43 Apr 10 2021 docker.cnf
- -rw-r--r-- 1 root root 1294 Dec 11 2020 mysql.cnf
- root@e62094f4ff02:/#
复制代码 免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |