ERROR 2002 mysql連接失敗 解決方法

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)



這個問題網上能夠查到很多資料,也照着試了,基本是這樣的:

1、/etc/init.d/mysql start

這時候會顯示上面的那個Error。

2、mysql -u root -p -S /var/run/mysqld/mysqld.sock

還是會出現上面的ERRor。網上查了下,說是訪問權限的問題,於是有了第三步。

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

4、/etc/init.d/mysql start


Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql start
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start mysql
mysql start/running, process 5855


終於能用了,執行了4的命令後,會在/var/run/mysqld 目錄出現mysqld.sock文件。

上面的5行提示說明這樣執行命令不太好,按照提示可以用:

sudo service mysql restart

在這裏記錄一下吧,目前還未發現出現這個問題的原因。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章