Detailed explanation of the pitfalls of recording lower_case_table_names in MySQL

Detailed explanation of the pitfalls of recording lower_case_table_names in MySQL

1 Cause

After the project migrated the database and restarted, an error message was displayed saying "T_AAA table does not exist", but the table can be seen in the database and has data

2 Problem Analysis

Reinstall the system and database to confirm that the system and database are clean. Eliminate the system and database as the cause. Use the same method to restore the data backup two days ago and one day ago. The project still cannot be started. Eliminate the cause of the data content. Use mysqldump and export SQL files to restore the data one day ago. The project still cannot be started. Eliminate the cause of the recovery method.

The above methods are basically participated by operation and maintenance personnel. After the technical director participated in observing the project error, he suddenly found that it was a problem with the upper and lower case of the table name. The cause was finally determined through testing:
Use the rpm package to install the database. Set lower_case_table_names to 0 during automatic initialization. The table name is case sensitive, lowercase in the database and uppercase in the code.

3 Solutions

  • Delete the initialized database, i.e. base_dir, data_dir, etc.
  • Reinitialize the database and set lower_case_table_names to 1
  • Restore backup data

4 Conclusion

For MySQL 8.0 and above, the lower-case-table-names parameter can only be set during initialization, and cannot be achieved by modifying my.cnf (adding configuration to my.cnf will result in an error)

To initialize the database, you do not need to uninstall the entire MySQL and reinstall it. You only need to use the mysqld command.

The user group of base_dir should be mysql. The command under Linux is:

chown -R mysql.mysql MySQL data path (i.e. base_dir)

Recursively create directories under Linux

mkdir -p mysql/lib/mysql-files

MySQL Reinitialization

mysqld -initialize --lower-case-table-names=1

For MySQL 8.0 and above, you need to create a user first and then grant permissions

create user 'test'@'%' identified by 'test';
-- with option can grant permissions to other users grant all privileges on test.* to 'test'@'%' with option;

This is the end of this article about the pitfalls of recording lower_case_table_names in MySQL. For more relevant MySQL lower_case_table_names content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed explanation of the pitfalls of MySQL 8.0
  • Some pitfalls that developers must pay attention to after upgrading to MySQL 5.7
  • A brief discussion on the pitfalls and solutions of the new features of MySQL 8.0 (summary)
  • Solution to the problem of null column in NOT IN filling pit in MySQL
  • How to use MySQL 5.7 temporary tablespace to avoid pitfalls
  • Mysql 5.7.19 free installation version encountered pitfalls (collection)
  • Pitfalls encountered when installing MySQL 8.0.18 compressed package and resetting forgotten passwords
  • Share MySql8.0.19 installation pit record

<<:  Pure CSS header fixed implementation code

>>:  Analyze the difference between querySelector and getElementById methods in JavaScript

Recommend

Linux firewall iptables detailed introduction, configuration method and case

1.1 Introduction to iptables firewall Netfilter/I...

WeChat applet implements calculator function

WeChat Mini Programs are becoming more and more p...

Detailed explanation of JavaScript animation function encapsulation

Table of contents 1. Principle of animation funct...

How to create, save, and load Docker images

There are three ways to create an image: creating...

Pay attention to the use of HTML tags in web page creation

HTML has attempted to move away from presentation...

Example code for implementing the "plus sign" effect with CSS

To achieve the plus sign effect shown below: To a...

Introduction to Sublime Text 2, a web front-end tool

Sublime Text 2 is a lightweight, simple, efficien...

Summary of using the exclamation mark command (!) in Linux

Preface Recently, our company has configured mbp,...

Solution to the problem that Navicat cannot remotely connect to MySql server

The solution to the problem that Navicat cannot r...

Example of adding attributes using style in html

Add inline styles to the required links: Copy code...

JS implements a stopwatch timer

This article example shares the specific code of ...

How to write high-quality JavaScript code

Table of contents 1. Easy to read code 1. Unified...

10 reasons why Linux is becoming more and more popular

Linux has been loved by more and more users. Why ...

jQuery canvas generates a poster with a QR code

This article shares the specific code for using j...