ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'解決
用XAMPP裝裝好mysql之後,mysql -uroot 連不上,報這個錯誤:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
在mysql的配置文件裡,/opt/lampp/etc/my.cnf, 發現了這樣的配置:
[java]
<span style="font-size:24px;"># The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /opt/lampp/var/mysql/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
user = nobody
port = 3306
socket = /opt/lampp/var/mysql/mysql.sock
</span>
原來mysql用的套接字文件是:/opt/lampp/var/mysql/mysql.sock於是建立了個軟連接, 命令如下。不能建立硬鏈接,不知道為什麼。
ln -s /opt/lampp/var/mysql/mysql.sock /var/run/mysqld/mysqld.sock
現在可以用mysql -uroot命令登陸上了~