mysql大小写敏感(默认为1,不敏感)

在 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: Identifier Case Sensitivity

How table and database names are stored on disk and used in MySQL is affected by thelower_case_table_names system variable, which you can set when starting mysqld.lower_case_table_names can take the values shown in the following table. This variable does notaffect case sensitivity of trigger identifiers. On Unix, the default value of lower_case_table_namesis 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 or CREATE DATABASE statement. Name comparisons are case sensitive. Note that if you force this variable to 0 with --lower-case-table-names=0 on a case-insensitive filesystem and access MyISAM tablenames using different lettercases, index corruption may result.
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 or CREATE DATABASE statement, but MySQL converts them to lowercase on lookup. Name comparisons are not case sensitive. This works onlyon filesystems that are not case sensitive! InnoDB table names are stored in lowercase, as for lower_case_table_names=1.
原文地址:https://www.cnblogs.com/cl1024cl/p/6205494.html