當我用PHP腳本連接我的數據庫,它顯示無法連接:無法通過套接字「/var/lib/mysql/mysql.sock」連接到本地MySQL服務器(2)
Could not connect: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
用戶名和密碼是正確的。
的my.cnf
[client]
#password = your_password
port = 3306
socket = /data/mysql/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port = 3306
socket = /data/mysql/mysql.sock
skip-external-locking
PS的東西:我將其更改爲socket = /var/lib/mysql/mysql.sock
PHP腳本仍然說 「/var/lib/mysql/mysql.sock」?然後運行
mysqladmin -u root -p status
它顯示
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
service mysqld restart
mysqld: unrecognized service
錯誤表明您正在嘗試使用'/ VAR/lib/mysql/mysql.sock'而您的配置建議套接字實際上位於'/ data/mysql/mysql.sock' ... – eggyal
我將它更改爲socket = /var/lib/mysql/mysql.sock錯誤仍然存在 – run
在Debian系統上重新啓動MySQL的命令服務器是'服務mysql重新啓動' –