啓動mysql 報錯:mysql
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
sql
一、先查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已經啓動.
shell
另外看看是否是權限問題.服務器
二、肯定你的mysql.sock是否是在那個位置,
socket
mysql -u 你的mysql用戶名 -p -S /var/lib/mysql/mysql.sockide
三、試試:service mysqld start
server
四、若是是權限問題,則先改變權限 #chown -R mysql:mysql /var/lib/mysql
it
[root@localhost ~]# /etc/init.d/mysqld start
io
啓動 MySQL: [ 肯定 ]class
[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 &
問題解決。