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 &
問題解決。
作者252831020