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銆佺‘瀹氫綘鐨刴ysql.sock鏄笉鏄湪閭d釜浣嶇疆錛?br /> 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 鐨勮闂潈闄愰棶棰樸?br />
shell> chown -R mysql:mysql /var/lib/mysql
鎺ョ潃鍚姩鏈嶅姟鍣?br />
shell> /etc/init.d/mysql start
鏈嶅姟鍣ㄦ甯稿惎鍔ㄥ悗瀵熺湅 /var/lib/mysql 鑷姩鐢熸垚mysql.sock鏂囦歡銆?br />
浣嗘槸鎴戠殑闂浠嶇劧娌℃湁寰楀埌瑙e喅銆?br />
闂緇堜簬瑙e喅錛?br />
鏂規硶錛?nbsp; 淇敼/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:
鍙戠幇渚濇棫濡傛錛岃繍琛?span id="ctl00_MainContentPlaceholder_ctl01_ctl00_lblEntry">/etc/init.d/mysql start鎶ラ敊錛?nbsp; Starting MySQLCouldn't find MySQL manager or server
鏄痬ysqld鏈嶅姟娌″惎錛岃繍琛?usr/local/mysql/bin/mysqld_safe &
闂瑙e喅銆?br />
chmod 700 /usr/local/mysql/data