最近在啟動mysql的時候發現mysql報錯了,錯誤代碼是2002,透過尋找相關的資料發現是var/lib/mysql 的存取權問題,所以這篇文章主要介紹了mysql中異常錯誤ERROR:2002的解決方法,需要的朋友可以參考借鑒,下面來一起看看吧。
最近在啟動mysql 報錯,錯誤提示如下:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock' (2)
排查過程
1、先查看/etc/rc.d/init.d/mysqld status
看看mysql是否已經啟動.
另外看看是不是權限問題.
##2 、確定你的mysql.sock是不是在那個位置,mysql -u 你的mysql用户名 -p -S /var/lib/mysql/mysql.sock
service mysqld start
#chown -R mysql:mysql /var/lib/mysql
[root@localhost ~]# /etc/init.d/mysqld start 启动 MySQL: [ 确定 ] [root@localhost ~]# mysql -u root -p
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
shell> chown -R mysql:mysql /var/lib/mysql
shell> /etc/init.d/mysql start
問題終於解決:
[mysqld] datadir=/usr/local/mysql/data socket=/var/lib/mysql/mysql.sock [mysql.server] user=mysql basedir=/usr/local/mysql If there is not currently a section called [client], add one at the bottom of the file and copy the socket= line under the [mysqld] section such as: [client] socket=/var/lib/mysql/mysql.sock
/etc/init.d/mysql start報錯:Starting MySQLCouldn't find MySQL manager or server是mysqld服務沒啟,運行
/usr/local/mysql/bin/mysqld_safe &
############ ###問題解決。 #########總結#######
以上是mysql中異常錯誤ERROR:2002的解決方法分享的詳細內容。更多資訊請關注PHP中文網其他相關文章!