lower_case_table_names=1 on Ubuntu 18.04 doesn't let mysql to start

后端 未结 5 689
抹茶落季
抹茶落季 2020-12-31 23:24

I have installed mysql community server 8.013 on ubuntu 18.04 and I have the following issue. I want to set lower_case_table_names=1 in order to have case insensitive table

相关标签:
5条回答
  • 2020-12-31 23:56

    You need to reinit MySQL data directory. According to https://dev.mysql.com/doc/refman/8.0/en/identifier-case-sensitivity.html lower_case_table_names can only be configured when initializing the server.

    You can do it using this script https://github.com/igrmk/ubuntu-reinit-mysql.

    Please note that your data will be DESTROYED! So create a backup before running it.

    0 讨论(0)
  • 2020-12-31 23:59

    Please go to below location and add the following code

    location - cd /etc/mysql/mysql.conf.d/

    then sudo vim mysqld.cnf

    next, add below under the [mysqld]

    lower_case_table_names=1
    
    0 讨论(0)
  • 2020-12-31 23:59

    I also had the same issue.

    I edited the /etc/mysql/conf.d/mysql.cnf file. (NOT the /etc/mysql/mysql.conf.d/mysqld.cnf file.)

    I inset the lower_case_table_names=1 just below [mysqld] line. (There were no lines below [mysqld] line below.

    Then I restarted mysql using sudo service mysql restart

    It solved my issue.

    0 讨论(0)
  • 2021-01-01 00:02

    This worked for me on a fresh Ubuntu Server 20.04 installation with MySQL 8.0.20 (no existing databases to care about - so if you have important data then you should backup/export it elsewhere before doing this):

    So... I did everything with elevated permissions:

    sudo su
    

    Install MySQL (if not already installed):

    apt-get install mysql-server
    

    Backup configuration file, uninstall it, delete all databases and MySQL related data:

    cp /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/mysql.conf.d/mysqld.cnf.backup
    service mysql stop
    apt-get --purge autoremove mysql-server
    rm -R /var/lib/mysql
    

    Restore saved configuration file, edit the file (add a line just under [mysqld] line):

    cp /etc/mysql/mysql.conf.d/mysqld.cnf.backup /etc/mysql/mysql.conf.d/mysqld.cnf
    vim /etc/mysql/mysql.conf.d/mysqld.cnf
    
    ...
    lower_case_table_names=1
    ...
    

    Reinstall MySQL (keeping the configuration file), configure additional settings:

    apt-get install mysql-server
    service mysql start
    mysql_secure_installation
    mysql
    
    SHOW VARIABLES LIKE 'lower_case_%';
    exit
    
    0 讨论(0)
  • 2021-01-01 00:15

    In order to make this work in MySQL 8.0 and linux follow the steps bellow

    0) Backup mysql schema before executing the following steps using

    mysqldump  -h localhost -u root -p mysql > /home/username/dumps/mysqldump.sql
    

    and then stop mysql using

    sudo service mysql stop
    

    1) move or remove /var/lib/mysql directory. This will delete all databases!!!!

    mv /var/lib/mysql /tmp/mysql
    

    2)Create a new /var/lib/mysql directory and make mysql user as owner

    mkdir /var/lib/mysql
    chown -R mysql:mysql /var/lib/mysql
    chmod 750 /var/lib/mysql
    

    3)edit /etc/mysql/mysql.conf.d/mysqld.cnf and add the following line after [mysqld]

    lower_case_table_names=1
    

    4) Initialize mysql using the following

    mysqld --defaults-file=/etc/mysql/my.cnf --initialize lower_case_table_names=1 --user=mysql --console

    Change defaults-file with the actual location of your defaults file. more info on mysql initialization here: https://dev.mysql.com/doc/refman/8.0/en/data-directory-initialization-mysqld.html

    5) (Optional) Repeat

    chown -R mysql:mysql /var/lib/mysql
    chmod 750 /var/lib/mysql
    

    if owner of the files in /var/lib/mysql is not mysql

    6)Start mysql using

    sudo service mysql start
    

    7) If everything worked correctly, open mysql using

    mysql -u root -p
    

    and by running this query

    SHOW VARIABLES where Variable_name like 'lower%';
    

    you will get

    'lower_case_table_names', '1'
    

    8)Restore mysql schema using the dump created in step 0.

    9)Execute mysql_upgrade to create the sys schema

    0 讨论(0)
提交回复
热议问题