Linux环境Mysql大小写敏感-不生效

tech2026-04-10  1

第一步:Linux下查看mysql默认采用的配置文件(正确找到mysql加载的my.cnf文件)

[root@localhost init.d]# mysql --help | grep 'Default options' -A 1Default options are read from the following files in the given order:/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf 

从左至右依次加载,如果存在则加载引用,否则,文件不存在则向后继续查找;

第二步:查看当前属性

SHOW variables LIKE '%table_names%';

value值为0:大小写敏感

value值为1:不区分大小写

第三步:配置过程(通常/etc/my.cnf由手工复制创建,名字及后缀要正确)

[root@localhost etc]# ll /etc/my.cnf  -rw-r--r--. 1 root root 211 9月   4 15:47 /etc/my.cnf[root@localhost etc]# vi my.cnf 

my.cnf[mysqId]下方添加lower_case_table_names=1

第四步:重启mysql

[root@localhost etc]# cat /etc/system-release  //查看一下系统版本 CentOS Linux release 7.8.2003 (Core)

开始重启mysql

[root@localhost etc]# systemctl restart mysql.service

第五步:测试是否生效

检查variables值&&选择SQL查询测试

最新回复(0)