在 MySQL 中,数据库和表其实就是数据目录下的目录和文件,因而,操作系统的敏感性决定数据库和表命名的大小写敏感。这就意味着数据库和表名在 Windows 中是大小写不敏感的,而在大多数类型的 Unix/Linux 系统中是大小写敏感的。
MySQL大小写敏感可以通过配置文件的lower_case_table_names参数来控制。
WINDOWS:
编辑MySQL安装目录下的my.ini 文件,在[mysqld]节下 添加 lower_case_table_names=0 (备注:为0时大小写敏感,为1时大小写不敏感,默认为1),可以实现MySql按照建表Sql语句的大小写状态来定义表名。
LINUX:
编辑/etc/my.cnf文件,在[mysqld]节下 添加 lower_case_table_names 参数,并设置相应的值 (备注:为0时大小写敏感,为1时大小写不敏感,默认为0)
PS:
How table and database names are stored on disk and used in MySQL is affected by thelower_case_table_names
lower_case_table_names
lower_case_table_names
is 0. On Windows the default value is 1. On Mac OS X, the default value is 2.
Value | Meaning |
0 |
Table and database names are stored on disk using the lettercase specified in the CREATE TABLE CREATE
DATABASE --lower-case-table-names=0 MyISAM |
1 |
Table names are stored in lowercase on disk and name comparisons are not case sensitive. MySQL converts all table names to lowercase on storage and lookup. This behavior also applies to database names and table aliases. |
2 |
Table and database names are stored on disk using the lettercase specified in the CREATE TABLE CREATE
DATABASE InnoDB lower_case_table_names=1 . |