Set the MySQL table name to be case insensitive.

Source: Internet
Author: User

In cross-platform programming, we should note that the default values of some MySQL System variables are different on Windows and Linux, such as the case variables of MySQL table names.

In Windows, the default value of the lower_case_table_names variable is 1, the value is 0 in Linux, and the value is 2 in Mac OS;

The variable value is defined as follows:

Value Meaning
0 Table and database names are stored on disk using the lettercase specified inCREATE TABLEOrCREATE DATABASEStatement. Name comparisons are case sensitive. You shocouldNotSet this variable to 0 if you are running MySQL on a system that has case-insensitive file names (such as Windows or Mac OS X). If you force this variable to 0--lower-case-table-names=0On a case-insensitive file system and accessMyISAMTablenames using different lettercases, index partition uption 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 inCREATE TABLEOrCREATE DATABASEStatement, but MySQL converts them to lowercase on lookup. Name comparisons are not case sensitive. This worksOnlyOn file systems that are not case sensitive!InnoDBTable names are stored in lowercase, aslower_case_table_names=1.

To set the table name to case insensitive in Linux, run the following command:

Mysqld -- SET-lower_case_table_names = 1;

You can also add configuration items to the MySQL server configuration file:

VI/etc/My. CNF

# The MySQL server[mysqld]set-variable=lower_case_table_names=1

Iefreer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.