Fedora8啟動mysql 報錯:
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
1、先查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已經啟動.
另外看看是不是許可權問題.
2、確定你的mysql.sock是不是在那個位置,
mysql -u 你的mysql使用者名稱 -p -S /var/lib/mysql/mysql.sock
3、試試:service mysqld start
4、如果是許可權問題,則先改變許可權 #chown -R mysql:mysql /var/lib/mysql
[root@localhost ~]# /etc/init.d/mysqld start
啟動 MySQL: [ 確定 ]
[root@localhost ~]# mysql -uroot -p
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
原因是,/var/lib/mysql 的存取權限問題。
shell> chown -R mysql:mysql /var/lib/mysql
接著啟動伺服器
shell> /etc/init.d/mysql start
伺服器正常啟動後察看 /var/lib/mysql 自動產生mysql.sock檔案。
但是我的問題仍然沒有得到解決。
問題終於解決:
方法: 修改/etc/my.conf:
[mysqld] datadir=/usr/local/mysql/data socket=/var/lib/mysql/mysql.sock [mysql.server] user=mysql basedir=/usr/local/mysql If there is not currently a section called [client], add one at the bottom of the file and copy the socket= line under the [mysqld] section such as: [client] socket=/var/lib/mysql/mysql.sock
發現依舊如此,運行/etc/init.d/mysql start報錯:Starting MySQLCouldn't find MySQL manager or server
是mysqld服務沒啟,運行/usr/local/mysql/bin/mysqld_safe &
問題解決。
原文地址:http://www.linuxdiyf.com/viewarticle.php?id=75335