ERROR 1146 (42S02): Table 'mysql.user' doesn't exist 解决方法

报错:

mysql>update mysql.user set authentication_string=password('neo666666') where user=r='root' and host='localhost';   #开始报错

ERROR 1146 (42S02): Table 'mysql.user' doesn't exist   #错误日志查看
mysql> flush privileges; 

ERROR 1146 (42S02): Table 'mysql.user' doesn't exist

一次源码新装的mysql,由于没有复制my-default.cnf到/etc/my.cnf位置,在启动mysql的时候碰到了无法打开mysql.user表的错误。具体错误为:[ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist。下面是该错误的描述及其解决办法。

#查看当前的my.cnf配置文件
[root@HKBO scripts]# more /etc/my.cnf |grep -v ^#
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
old_passwords=1

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

#由于编译安装时指定的路径为/www/lanmps/mysql5.7.20/data以及mysql_install_db时指定的datadir也为/www/lanmps/mysql5.7.20/data,而my.cnf为缺省的路径

#因此修改datadir至正确路径后,问题解决,Let's go!!!立马可以登录了哈!如下图所示:

ERROR 1146 (42S02): Table 'mysql.user' doesn't exist 解决方法_第1张图片



你可能感兴趣的:(mysql)