1. 程式人生 > >[ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist

[ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist

這個問題是由於data的目錄下沒有安裝資料庫表

解決方法:

vi /etc/my.cnf

修改為正確的datadir=“xxxxx”即可

然後service mysqld start

service mysql start

正常啟動後,會再/var/lib/mysql下面生成mysql.sock檔案,

然後還報:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'

可以指定mysql.sock路徑:

mysql -u root -p -S /var/lib/mysql/mysql.sock

還有有時候是你的目錄許可權的問題:

記得賦許可權:chown -R mysql:mysql  /usr/local/mysql