Home  >  Article  >  Database  >  How to make mysql case insensitive

How to make mysql case insensitive

青灯夜游
青灯夜游Original
2022-06-20 14:40:1546472browse

How to make mysql case-insensitive: 1. Enter the installation directory of mysql, find and open the configuration file "my.ini"; 2. Add the "lower_case_table_names=1" statement to the last line of the configuration file , set the case-sensitive parameter "lower_case_table_names" to make mysql insensitive to case; 3. Restart the mysql service.

How to make mysql case insensitive

The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.

How to make mysql case-insensitive

Mysql case-sensitive configuration is related to two parameters - lower_case_file_system and lower_case_table_names

  • lower_case_file_system: Indicates whether the current system file is case-sensitive (ON means insensitive, OFF means sensitive), a read-only parameter that cannot be modified.

  • lower_case_table_names: Indicates whether the table name is case-sensitive and can be modified.

The lower_case_file_system parameter cannot be modified, so the lower_case_table_names parameter can only be used to make mysql case-insensitive.

Steps:

1. Enter the mysql installation directory, find and open the configuration file my.ini

How to make mysql case insensitive

2. Add the following sentence to the last line of the configuration file

lower_case_table_names=1

lower_case_file_system indicates whether the file system where the data directory is located is sensitive to the case of the file name

  • 0: Case-sensitive

  • 1: Case-insensitive

How to make mysql case insensitive

3, Just restart the mysql service.

Note:

To set the default lower_case_tables_name from 0 to 1, you need to convert the existing library table name to lowercase first:

1) For the case where only uppercase letters exist in the table name:

①, when lower_case_tables_name=0, execute rename table to lowercase.

②. Set lower_case_tables_name=1 and it will take effect after restarting.

2) For the case where uppercase letters exist in the library name:

① When lower_case_tables_name=0, use mysqldump to export and delete the old database.

②. Set lower_case_tables_name=1 and it will take effect after restarting.

③. Import data into the instance. At this time, the library name containing uppercase letters has been converted to lowercase.

[Related recommendations: mysql video tutorial]

The above is the detailed content of How to make mysql case insensitive. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn