MySQL [ERROR] Table ‘mysql.user’ doesn’t exist

Problem Description:

When installing mysql,/etc/init.d/mysqld start reported an error:

[root@master data]# /etc/init.d/mysqld start
Starting MySQL.. ERROR! The server quit without updating PID file (/var/lib/mysql/master.pid).

Solution steps:

1. Check the script when installing MySQL and the specified file

2. Check mariadb.log to find related errors:

[ root@master init.d]# cd /var/log/mariadb
[ root@master mariadb]# ls
mariadb.log

The specific error is: [error] fatal error: can’t open and lock privilege tables: table ‘mysql. User’ doesn’t exist. Here is a description of the error and its solution

#View the current my.cnf configuration file

[root@master mariadb]#  more /etc/my.cnf |grep -v ^#
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0

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

!includedir /etc/my.cnf.d

#Because the path specified during compilation and installation is/MNT/MySQL/data and mysql_ install_ The dataDir specified in DB is also/MNT/MySQL/data:

/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/mnt/mysql/data --user=mysql

The path specified by my.cnf is

/var/lib/mysql

#So modify the dataDir to the correct path:

[root@master mariadb]#  more /etc/my.cnf |grep -v ^#
[mysqld]
datadir=/mnt/mysql/data
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

!includedir /etc/my.cnf.d

[root@master mariadb]# service mysqld start
Starting MySQL. SUCCESS!

Similar Posts: