Solve the case sensitivity problem of mysql in Linux docker

Note: mysql5.7 is the name of the mysql container in docker in this example.

Enter the mysql container:

docker exec -it mysql5.7 /bin/bash

Log in to mysql as root user:

mysql -u root -p
Insert picture description here

View the current case-sensitive configuration of mysql:

show global variables like '%lower_case%';
Insert picture description here


lower_case_file_system indicates whether the current system file is case-sensitive, a read-only parameter, and cannot be modified.
ON means case is not sensitive.
OFF means case sensitive.
Since vi or vim is not installed in the container, copy the configuration file from the container and copy it to the container after modification.
Copy files from the container to the host/data directory:

 docker cp mysql5.7:/etc/mysql/mysql.conf.d/mysqld.cnf /data

Add after mysqld:

lower_case_table_names=1
Insert picture description here

Copy the modified file to the container:

 docker cp /data/mysqld.cnf mysql5.7:/etc/mysql/mysql.conf.d

Restart mysql:

docker restart mysql5.7

View the current case-sensitive configuration of mysql:

show global variables like '%lower_case%';
Insert picture description here