Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist

前端 未结 18 2138
轮回少年
轮回少年 2020-12-04 15:29

I am on a server that has afresh install on RHEL 5. I was able to install Apache and PHP just fine., but I am having serious trouble with my MySQL installation. I tried t

相关标签:
18条回答
  • 2020-12-04 15:58

    The root of my problem seemed to be selinux, which was turned on (enforcing) automatically on OS install.

    I wanted my mysql in /data.

    After verifying that my.cnf had:

    datadir=/data/mysql
    

    (and leaving the socket at /var/lib/mysql) I executed the command to turn off selinux for mysqld (alternative is to turn it off completely):

    setsebool -P mysqld_disable_trans=1
    

    I ran the following commands:

    > chown -R mysql .
    > chgrp -R mysql .
    > mysql_install_db --user=mysql
    

    I started the mysql daemon and everything worked fine after that.

    0 讨论(0)
  • 2020-12-04 15:58

    I just met the same problem with mysql 5.7 on OSX:

    rm -rf {datadir}
    mysqld --initialize --datadir {datadir}
    mysqld --datadir {datadir}
    
    0 讨论(0)
  • 2020-12-04 16:01

    In my case the path of MySQL data folder had a special character "ç" and it make me get...

    Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist.

    I'm have removed all special characters and everything works.

    0 讨论(0)
  • 2020-12-04 16:03

    I had the same issue in trying to start the server and followed the "checked" solution. But still had the problem. The issue was the my /etc/my.cnf file was not pointing to my designated datadir as defined when I executed the mysql_install_db with --datadir defined. Once I updated this, the server started correctly.

    0 讨论(0)
  • 2020-12-04 16:03

    My case on Ubuntu 14.04.2 LTS was similar to others with my.cnf, but for me the cause was a ~/.my.cnf that was leftover from a previous installation. After deleting that file and purging/re-installing mysql-server, it worked fine.

    0 讨论(0)
  • 2020-12-04 16:04

    When download mysql zip version, if run mysqld directly, you'll get this error: 2016-02-18T07:23:48.318481Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist 2016-02-18T07:23:48.319482Z 0 [ERROR] Aborting

    You have to run below command first: mysqld --initialize

    Make sure your data folder is empty before this command.

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