I can get it to work with a workaround. By re-initializing MySQL with the new value for lower_case_table_names after its installation. The following steps apply to a new installation. If you have already data in a database, export it first to import it back later:
Install MySQL: 1 2 sudo apt-get update sudo apt-get install mysql-server -y
Stop the MySQL service:
Delete the MySQL data directory: 1 sudo rm -rf /var/lib/mysql
Recreate the MySQL data directory (yes, it is not sufficient to just delete its content): 1 2 3 sudo mkdir /var/lib/mysql sudo chown mysql:mysql /var/lib/mysql sudo chmod 700 /var/lib/mysql
Add lower_case_table_names = 1
to the [mysqld]
section in /etc/mysql/mysql.conf.d/mysqld.cnf
. Re-initialize MySQL with --lower_case_table_names=1
: 1 sudo mysqld --defaults-file=/etc/mysql/my.cnf --initialize --lower_case_table_names=1 --user=mysql --console
Start the MySQL service: 1 sudo service mysql start
Retrieve the new generated password for MySQL user root: 1 sudo grep 'temporary password' /var/log/mysql/error.log
Change the password of MySQL user root either by:
and executing:
1 ALTER USER 'root' @'localhost' IDENTIFIED BY 'MyNewPa$$w0rd' ;
afterwards, OR by calling the “hardening” script anyway:
1 sudo mysql_secure_installation
After that, you can verify the lower_case_table_names setting by entering the MySQL shell:
and executing:
1 SHOW VARIABLES LIKE 'lower_case_%' ;
Expected output:
1 2 3 4 5 6 +------------------------+ -------+| Variable_name | Value | +------------------------+-------+ | lower_case_file_system | OFF | | lower_case_table_ names | 1 |+------------------------+ -------+
转载请注明出处: 安装MySQL并设置lower_case_table_names参数 原文地址: https://www.xiaotanzhu.com/mysql/2021-07-24-install-mysql-with_lowercasetablenames.html