1. 程式人生 > >Mysql -- connect MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Mysql -- connect MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

背景:

以如下方式連線本機的mysql服務

mysql -h localhost -P 3306 -u root -p pwd
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

結果報了上面的錯誤,改為以下的方式解決問題。

mysql -h 127.0.0.1 -P 3306 -u root -p pwd