亲宝软件园·资讯

展开

docker mysql5.7不区分大小写

tiger_angel 人气:0

进入容器后

mysql 配置文件是放在 /etc/mysql/mysql.conf.d/mysqld.cnf,

vim /etc/mysql/mysql.conf.d/mysqld.cnf 在 [mysqld] 下加入一行: lower_case_table_names=1

或 

docker run -p 3306:3306 --name mymysql -v $PWD/conf:/etc/mysql/conf.d -v $PWD/logs:/logs -v $PWD/data:/mysql_data -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7 --lower_case_table_names=1

在宿主机改好

[mysqld]
#不区分大小写lower_case_table_names=1
lower_case_table_names=1
pid-file    = /var/run/mysqld/mysqld.pid
socket        = /var/run/mysqld/mysqld.sock
datadir        = /var/lib/mysql
#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

也可以在宿主机改好用docker命令cp到容器里面

docker cp  mysqld.cnf mysql:/etc/mysql/mysql.conf.d/mysqld.cnf

重启mysql容器

docker restart mysql

保存,退出容器;

执行sudo docker restart MySQL ,重启MySQL即可查看:

show global variables like '%lower_case%';
+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| lower_case_file_system | OFF   |
| lower_case_table_names | 1     |
+------------------------+-------+
2 rows in set (0.00 sec)

加载全部内容

相关教程
猜你喜欢
用户评论