MySQL Variables lower_case_table_names 数据库 参数变量解释及正确配置使用

本站中文解释

lower_case_table_names是MySQL的一个提供系统参数,用于定义MySQL在Linux下的表名的大小写地使用方式。其可取的参数值有三种:

– 0:表名大小写敏感。就是说MySQL会在Linux环境下严格区分表名的大小写;
– 1:忽略表名的大小写。就是说MySQL会将表名的中的字母转换为小写形式后再进行访问;
– 2:此参数仅支持Windows文件系统,它强制表名大小写与Windows文件系统中表名保持一致。

用户可以通过编辑MySQL系统参数文件my.cnf,添加或修改lower_case_table_names参数的参数值,从而设置MySQL在Linux环境下表名的大小写使用方式。

官方英文解释

lower_case_table_names

Command-Line Format --lower-case-table-names[=#]
System Variable lower_case_table_names
Scope Global
Dynamic No
Type Integer
Default Value (macOS) 2
Default Value (Unix) 0
Default Value (Windows) 1
Minimum Value 0
Maximum Value 2

If set to 0, table names are stored as specified and
comparisons are case-sensitive. If set to 1, table names are
stored in lowercase on disk and comparisons are not
case-sensitive. If set to 2, table names are stored as given
but compared in lowercase. This option also applies to
database names and table aliases. For additional details, see
Section 9.2.3, “Identifier Case Sensitivity”.

The default value of this variable is platform-dependent (see
lower_case_file_system). On
Linux and other Unix-like systems, the default is
0. On Windows the default value is
1. On macOS, the default value is
2. On Linux (and other Unix-like systems),
setting the value to 2 is not supported;
the server forces the value to 0 instead.

You should not set
lower_case_table_names to 0
if you are running MySQL on a system where the data directory
resides on a case-insensitive file system (such as on Windows
or macOS). It is an unsupported combination that could result
in a hang condition when running an INSERT INTO ...
SELECT ... FROM tbl_name

operation with the wrong tbl_name
lettercase. With MyISAM, accessing table
names using different lettercases could cause index
corruption.

An error message is printed and the server exits if you
attempt to start the server with
--lower_case_table_names=0 on
a case-insensitive file system.

The setting of this variable affects the behavior of
replication filtering options with regard to case sensitivity.
For more information, see Section 16.2.5, “How Servers Evaluate Replication Filtering Rules”.


数据运维技术 » MySQL Variables lower_case_table_names 数据库 参数变量解释及正确配置使用