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

前端 未结 18 2139
轮回少年
轮回少年 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条回答
  • I had this issue on arch linux as well. The issue was pacman installed the package in a different location than MySQL was expecting. I was able to fix the issue with this:

    sudo mysql_install_db --user=mysql --basedir=/usr/ --ldata=/var/lib/mysql/
    

    Hope this helps someone!

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

    Just this command is enough to do the magic on centos 6.6

    mysql_install_db

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

    I got similar error on overlayfs (overlay2) that is the default on Docker for Mac. The error happens when starting mysql on the image, after creating a image with mysql.

    2017-11-15T06:44:22.141481Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table storage engine for 'user' doesn't have this option
    

    Switching to "aufs" solved the issue. (On Docker for Mac, the "daemon.json" can be edited by choosing "Preferences..." menu, and selecting "Daemon" tab, and selecting "Advanced" tab.)

    /etc/docker/daemon.json :

    {
      "storage-driver" : "aufs",
      "debug" : true,
      "experimental" : true
    }
    

    Ref:

    https://github.com/moby/moby/issues/35503

    https://qiita.com/Hige-Moja/items/7b1208f16997e2aa9028

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

    initialize mysql before start on windows.

    mysqld --initialize
    
    0 讨论(0)
  • 2020-12-04 15:57
    1. Uninstall mysql using yum remove mysql*

    2. Recursively delete /usr/bin/mysql and /var/lib/mysql

    3. Delete the file /etc/my.cnf.rmp

    4. Use ps -e to check the processes to make sure mysql isn't still running.

    5. Reboot server with reboot

    6. Run yum install mysql-server. This also seems to install the mysql client as a dependency.

    7. Give mysql ownership and group priveleges with:

      chown -R mysql /var/lib/mysql

      chgrp -R mysql /var/lib/mysql

    8. Use service mysqld start to start MySQL Daemon.

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

    If you move your datadir, you not only need to give the new datadir permissions, but you need to ensure all parent directories have permission.

    I moved my datadir to a hard drive, mounted in Ubuntu as:

    /media/*user*/Data/
    

    and my datadir was Databases.

    I had to set permissions to 771 to each of the media, user and Data directories:

    sudo chmod 771 *DIR*
    

    If this does not work, another way you can get mysql to work is to change user in /etc/mysql/my.cnf to root; though there are no doubt some issues with doing that from a security perspective.

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