MySQL.sock 丟失後怎麼連接數據庫?
請注意,如果你指定localhost 作為一個主機名, mysqladmin 默認使用Unix套接字文件連接,而不是TCP/IP。從MySQL 4.1 開始,通過--protocol= TCP |SOCKET | PIPE | MEMORY}選項,你可以顯示地指定連接協議,舉例如下:
socket 連接:
[zzx@zzx mysql]$ MySQL -uroot
ERROR 2002 (HY000): Can't connect to local MySQL Server through socket
'/home/zzx/mysql/MySQL.sock' (2)
tcp 連接:
[zzx@zzx mysql]$ MySQL --protocol=TCP -uroot -p -P3307 -hlocalhost
Enter passWord:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 73 to server version: 5.0.15-standard
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
MySQL>