1. 程式人生 > >ubuntu下mysql連結出現錯誤:Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

ubuntu下mysql連結出現錯誤:Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

轉自:https://www.cnblogs.com/adolfmc/p/5875584.html

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
原因是,/var/lib/mysql 的訪問許可權問題。

終端輸入:

chown -R mysql:mysql /var/lib/mysql

接著啟動伺服器,終端輸入:

/etc/init.d/mysql start

伺服器正常啟動後察看 /var/lib/mysql 自動生成mysql.sock檔案。

 

然後再登入mysql看看。

 

根據大佬的回答,我用這個方法解決了我的問題。