Change MySQL table and field case sensitivity

Source: Internet
Author: User

Database and table names are case insensitive in Windows, and are case sensitive on most types of Unix systems
The Windows version of MySQL defaults to the case of the OS, even if there is a distinction in SQL, the import will be converted to lowercase, if you will export this database in the future there may be case case. My.ini has properties lower_case_table_names can change this default, to be strictly case-sensitive, set this entry to 2, and then restart the MySQL service.
Reference:
[Mysqld]
lower_case_table_names=2 if not, you canadd a line in the MySQL configuration file My.ini [mysqld]

Lower_case_table_names = 2

Note: My.ini is not in \ c Program Files\mysql\mysql Server 5.5, but in: \ c ProgramData\mysql\mysql Server 5.5\my.ini

However, the query is available in Windows. To avoid differences, it is best to use a consistent conversion, such as always creating and referencing the database name and table name in lowercase. This conversion is recommended in most porting and use.

How to save and use table names and database names on your hard disk in MySQL is determined by the LOWER_CASE_TABLES_NAME system variable and can be set when you start mysqld . Lower_case_tables_name can take any of the following values:

Value

Meaning

0

Save the table name and database name on your hard disk using the uppercase and lowercase specified by the CREATE TABLE or CREATE DATABASE statement. The name comparison is case sensitive. This is the default setting in UNIX systems. Note that if you force the--lower-case-table-names=0 to 0 on a case-insensitive file system and access the MyISAM table name with a different casing, the index corruption will occur.

1

The table name is saved in lowercase on the hard disk, and the name comparison is case sensitive. MySQL converts all table names to lowercase for storage and lookup. This behavior is also appropriate for database names and table aliases. This value is the default value in Windows and Mac OS x systems.

2

The table name and database name are saved on the hard disk using the case specified by the CREATE TABLE or CREATE DATABASE statement, but MySQL converts them to lowercase for lookup. The name comparison is case sensitive. Note: applies only on file systems that are not case sensitive! InnoDB table names are saved in lowercase, such as lower_case_tables_name=1.

Change MySQL table and field case sensitivity

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.