Saturday, April 7, 2012

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

設定MySQL on Fedora時候,當mysql.sock不存在時,嘗試登入mysql root(mysql -u root -p)時候會出現:
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'(2)
 即使touch該檔案(sudo touch /var/lib/mysql/mysql.sock)還是會出現:

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'(111)
其實問題出在沒有啟動mysql,故需要以下指令即可:
sudo /etc/init.d/mysqld start