linux下mysql表名大小写敏感问题

时间:2021-10-13 08:20:21

环境:

[root@localhost etc]# lsb_release -a
LSB Version: :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 5.6 (Tikanga)
Release: 5.6
Codename: Tikanga
......

mysql> show variables like '%case%';

+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| lower_case_file_system | OFF   | 
| lower_case_table_names | 0     | 
+------------------------+-------+
2 rows in set (0.00 sec)


mysql> 


LINUX下的MYSQL默认是要区分表名大小写的, 让MYSQL不区分表名大小写的方法:
  1.用ROOT登录,修改/etc/my.cnf
  2.在[mysqld]下加入一行:lower_case_table_names=1
  3.重新启动数据库即可

......

修改后:

mysql> show variables like '%case%';

+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| lower_case_file_system | OFF   | 
| lower_case_table_names | 1     | 
+------------------------+-------+
2 rows in set (0.00 sec)


mysql>