Can't open and lock privilege tables: Table 'mysql.user' doesn't exist

时间:2022-09-20 08:30:05

       今天,登陆阿里云账号后,发现服务器有一个警告说有漏洞,修复完后要重启服务器,想都没想直接重启了。。。

       接下来事情发生了,想着直接重启mysql就行。

      现象描述
              [root@iZwz952coo41my3i5b7x2iZ ]# service mysqld start
              Starting MySQL..The server quit without updating PID file (/usr/local/mysql/data/mysql/iZwz952coo41my3i5b7x2iZ.pid).[FAILED]

       启动数据库失败了,然后去找iZwz952coo41my3i5b7x2iZ.err这个文件,发现下面这一行:

        Can't open and lock privilege tables: Table 'mysql.user' doesn't exist

         解决方法:

                #查看/etc/my.cnf配置文件

                Can't open and lock privilege tables: Table 'mysql.user' doesn't exist

             #由于编译安装mysql时指定的路径为/usr/local/mysql以及mysql_install_db时指定的datadir也为/usr/local/mysql,而my.cnf为缺省的路径
     #因此修改datadir为正确路径后,问题解决

               [root@iZwz952coo41my3i5b7x2iZ ]# service mysqld start
     Starting MySQL.[  OK  ]