Technology Encyclopedia Home >How to modify the sensitivity of table names after TDSQL-C MySQL version is initialized?

How to modify the sensitivity of table names after TDSQL-C MySQL version is initialized?

To modify the sensitivity of table names in TDSQL-C MySQL version after initialization, you can adjust the lower_case_table_names system variable. This variable controls whether table names are stored in lowercase or preserve their original case, and it also affects how table names are compared.

Explanation:

  • lower_case_table_names=0: Table names are stored as they are and comparisons are case-sensitive.
  • lower_case_table_names=1: Table names are stored in lowercase and comparisons are case-insensitive.
  • lower_case_table_names=2: Table names are stored as they are but comparisons are case-insensitive.

Steps to Modify:

  1. Connect to your TDSQL-C instance: Use a MySQL client to connect to your database.
  2. Check the current setting: Run the command SHOW VARIABLES LIKE 'lower_case_table_names';.
  3. Modify the setting: If you need to change it, you will typically do this by setting the variable in your MySQL configuration file (my.cnf or my.ini) under the [mysqld] section:
    [mysqld]
    lower_case_table_names=1
    
  4. Restart the MySQL service: After saving the changes, restart the MySQL service to apply the new configuration.

Example:

If you want to make table names case-insensitive:

  1. Open your MySQL configuration file.
  2. Add or modify the line:
    lower_case_table_names=1
    
  3. Save the file and restart MySQL.

Note:

Changing lower_case_table_names after the database has been initialized can lead to issues if there are existing tables with names that conflict under the new sensitivity rules. It is recommended to set this variable correctly at the time of initialization to avoid such issues.

For cloud-based solutions, consider using Tencent Cloud's TDSQL-C service, which provides managed MySQL databases with flexible configuration options to suit your needs.