mkdir -p /home/huangliang/mysql/data mkdir -p /home/huangliang/mysql/config
cd /home/huangliang/mysql/config vi mysqld.cnf
文件mysqld.cnf配置如下
[mysqld] pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock datadir = /var/lib/mysql lower_case_table_names=1 #lower_case_table_names: 此参数不可以动态修改,必须重启数据库 #lower_case_table_names = 1 表名存储在磁盘是小写的,但是比较的时候是不区分大小写 #lower_case_table_names=0 表名存储为给定的大小和比较是区分大小写的 #ower_case_table_names=2, 表名存储为给定的大小写但是比较的时候是小写的 #log-error = /var/log/mysql/error.log # By default we only accept connections from localhost #bind-address = 127.0.0.1 # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # 是否支持符号链接,即数据库或表可以存储在my.cnf中指定datadir之外的分区或目录,为0不开启
docker run -itd \ --privileged=true \ --restart=always \ --name mysql-test \ -p 33306:3306 \ -e MYSQL_ROOT_PASSWORD=123456 \ -v /home/huangliang/mysql/data:/var/lib/mysql \ -v /home/huangliang/mysql/config:/etc/mysql/conf.d \ -v /home/huangliang/mysql/logs:/var/log/mysql \ mysql \
不挂盘直接部署:
docker run -itd --name mysql5.7 -p 33336:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql:5.7.11