Can't connect to local MySQL server through socket

Mysql連接提示:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

如下:

  1. [root@cacti01 ~]# mysql 
  2. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 
  3. [root@cacti01 ~]# mysql -h localhost -p -u root 
  4. Enter password:  
  5. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 

而那個文件是壓根不存在的:

  1. [root@cacti01 ~]# more /var/lib/mysql/mysql.sock 
  2. /var/lib/mysql/mysql.sock: No such device or address 

經查爲mysqld服務沒啓動,啓動後登錄正常。

  1. [root@cacti01 ~]# service mysqld start 
  2. Starting mysqld:                                           [  OK  ] 
  3. [root@cacti01 ~]# mysql 
  4. Welcome to the MySQL monitor.  Commands end with ; or \g. 
  5. Your MySQL connection id is 2 
  6. Server version: 5.1.61 Source distribution 
  7.  
  8. Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 
  9.  
  10. Oracle is a registered trademark of Oracle Corporation and/or its 
  11. affiliates. Other names may be trademarks of their respective 
  12. owners. 
  13.  
  14. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 
  15.  
  16. mysql> 

狀態查詢:

  1. [root@cacti01 ~]# service mysqld status 
  2. mysqld (pid  16211) is running... 

正常後上面的那個文件還是不存在的,所以跟那個沒有關係。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章