mysql server有个参数叫做 lower_case_table_names,控制表名、字段名的大小写
它可以有3个值:
0:大小写敏感
1:比较名字时 忽略大小写,但创建表时,大写字母也转为小写字母。
2:比较名字时 忽略大小写,创建表时,维持原样。
查看:
[root@bbmg-law-test-01 ~]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 1745 Server version: 5.7.33 MySQL Community Server (GPL) Copyright (c) 2000, 2021, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. mysql> use mysql; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> show variables like 'lower_case_table_names'; +------------------------+-------+ | Variable_name | Value | +------------------------+-------+ | lower_case_table_names | 0 | +------------------------+-------+ 1 row in set (0.00 sec)
修改:
在my.cnf配置文件中[mysqld]标签的作用区域,增加lower_case_table_names=1的配置,然后重启MySQL服务
[root@bbmg-law-test-01 ~]# vim /etc/my.cnf
在mysqld下 添加或修改 lower_case_table_names = 1
[root@bbmg-law-test-01 ~]# service mysqld restart
再次查看: