MySQL 8.0 version lower_case_table_names parameter stepping record

Today I installed a MySQL 8.0.23 using a binary package, and did not configure lower_case_table_names=1 in my.cnf in advance during initialization. It is normal to start MySQL after initialization. Thinking of adding a parameter that ignores case into my.cnf, start MySQL after adding it, but it can't start, check the log and find the following error message:

[2021/3/18 10:23:27] 2021-03-18T10:23:04.224077+08:00 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
[2021/3/18 10:23:27] 2021-03-18T10:23:05.274659+08:00 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
[2021/3/18 10:23:27] 2021-03-18T10:23:05.308562+08:00 1 [ERROR] [MY-011087] [Server] Different lower_case_table_names settings for server ('1') and data dictionary ('0').
[2021/3/18 10:23:27] 2021-03-18T10:23:05.308950+08:00 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
[2021/3/18 10:23:27] 2021-03-18T10:23:05.309295+08:00 0 [ERROR] [MY-010119] [Server] Aborting
[2021/3/18 10:23:27] 2021-03-18T10:23:05.861083+08:00 0 [System] [MY-010910] [Server] /usr/local/mysql/bin/mysqld: Shutdown complete (mysqld 8.0.23)  MySQL Community Server - GPL.

If there is a problem, solve the problem.

Language first explain the lower_case_table_names parameter.

lower_case_table_names is a case-sensitive attribute of mysql. This parameter cannot be modified dynamically.

Defaults:

  • The default value under unix, linux is 0

  • The default value under Windows is 1

  • The default value under Mac OS is 2

View the official MySQL documentation:

MySQL 8.0 Release Notes - Changes in MySQL 8.0.17 (2019-07-22, General Availability) - Functionality Added or Changed有记录:

In MySQL 8.0, the lower_case_table_names variable can only be configured when the MySQL server is initialized.

Check the official website 8.0 document (5.7.x does not have this content), you can see:

There is a record in Language Structure-Schema Object Names-Identifier Case Sensitivity:

lower_case_table_names can only be configured when initializing the server. Changing the lower_case_table_names setting after the server is initialized is prohibited.
#意思是只能在初始化时指定 lower_case_table_names 参数,初始化之后该参数不允许修改。

For the case configuration problem, comparing the 8.0 and 5.7 documents, you will find that the 5.7 version supports modifying the lower_case_table_names parameter after initialization, and also provides a migration plan for databases created under different values.

In 8.0, only the parameter specified during initialization is supported. After initialization, if the parameter is modified, an error will be reported at startup because it is not allowed to modify this value after initialization.

It's easy to know the rules of MySQL

If data migration is not required:

Delete all files in the data directory, reinitialize and specify the lower_case_table_names value.

Uninstall MySQL, then reinstall, after reinstalling, specify the lower_case_table_names value when initializing the database.

If data migration is required, the general steps are as follows:

First convert the database name, table name, and field name to the desired case, and then export the data.

Reinitialize the database with the new lower_case_table_names value.

Create a new instance and import the previously exported data.

Two ways to specify lower_case_table_names:

  1. It is valid to set lower_case_table_names=1 during initialization, for example:
/usr/local/mysql/bin/mysqld  --defaults-file=/etc/my.cnf --initialize-insecure --user=mysql --initialize --lower-case-table-names=1
  1. Before initialization, modify the file my.cnf under linux and add lower-case-table-names=1 under the [mysqld] configuration node

Guess you like

Origin blog.51cto.com/5924778/2673853