lower_case_table_names Settings in MySQL 8.0.12

跟風遠走 提交于 2019-12-01 07:15:27

问题


I've just compiled the version MySQL 8.0.12 in a Ubuntu 16.0.4.

After following the instructions in the website and making the following my.cnf file:

[mysqld]
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
port=3306
log-error=/usr/local/mysql/data/localhost.localdomain.err
user=mysql
secure_file_priv=/usr/local/mysql/mysql-files
local_infile=OFF

log_error = /var/log/mysql/error.log

# Remove case sensitive in table names
lower_case_table_names=1

I get the following error:

2018-08-11T19:45:06.461585Z 1 [ERROR] [MY-011087] [Server] Different lower_case_table_names settings for server ('1') and data dictionary ('0').

What should I change so that data dictionary is aligned to server settings?


回答1:


As per this link, lower_case_table_names should be set together with --initialize option.




回答2:


I had the same problem and as described here https://bugs.mysql.com/bug.php?id=90695 this is not supported out of the box. So the workaround that I did in order to make it work was this lower_case_table_names=1 on Ubuntu 18.04 doesn't let mysql to start




回答3:


MySQL Documentation says

lower_case_table_names can only be configured while initializing the server. Changing the lower_case_table_names setting after the server is initialized is prohibited.

https://dev.mysql.com/doc/refman/8.0/en/identifier-case-sensitivity.html




回答4:


To fix this issue,

  1. Just take the backup of the existing db Schema using the following command inside bin folder (/usr/local/mysql/bin) ./mysqldump -uroot -p password > dump.sql

  2. Once the backup is taken delete the existing data folder in Mysql Home(/usr/local/mysql/) using the command rm -rf data

  3. Now add the configuration as "lower_case_table_names=1" in my.cnf under MYSQLD section (/etc/my.cnf)

  4. Now Initialize the data directory using the following command inside bin directory (/usr/local/mysql/bin)

For Secure mode ./mysqld --defaults-file=/etc/my.cnf --initialize --user=mysql --console

For Insecure mode ./mysqld --defaults-file=/etc/my.cnf --initialize-insecure --user=mysql --console

  1. Once the data directory initialized, For Insecure mode repeat the Installation again and For Secure mode use the root password which is initialized during the run time of data directory Initialization.

  2. Now import the existing dump file inside the Mysql Server using the command inside (/usr/local/mysql/bin) directory

./mysql -uroot -p password < file.sql




回答5:


To solve your problem:

1.stop mysql:

systemctl stop  mysql

2.clean data directory or change the default, the following is for new installations , if you have data in your database BACK UP them beforehand

rm -rf /var/lib/mysql

3.Insert lower_case_table_names = 1 in your my.cnf:

[mysqld]
lower_case_table_names=1

4.Start again

systemctl start mysqld


来源:https://stackoverflow.com/questions/51803216/lower-case-table-names-settings-in-mysql-8-0-12

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!