ERROR 2002 (HY000): Can't connect server socket /tmp/mysql.sock

starive發表於2014-09-28
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)


自己採用的解決方案:
啟動MySQL資料庫:


***@***-VirtualBox:~$ sudo /etc/init.d/mysql.server start
Starting MySQL
.... * The server quit without updating PID file (/usr/local/mysql/data/***-VirtualBox.pid).

針對以上錯誤,網上各種百度,各種谷歌都解決不了,還是提示上面的同樣的錯誤


我採用下面的方法,竟然可以啟動MySQL,但是又引發了其他的無法解決的error
##################################    方法如下    ##############################
按照網址http://www.justin.my/2012/03/starting-mysql-error-the-server-quit-without-updating-pid-file/
竟然可以啟動MySQL服務,如下:
***@***-VirtualBox:/etc$ sudo mv /etc/my.cnf /etc/my.cnf.old
***@***-VirtualBox:/etc$ sudo /etc/init.d/mysql.server start
Starting MySQL
.. * 

但是,無法登陸了:
***@***-VirtualBox:/etc/mysql/conf.d$ sudo mysql -u root -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)


這個錯誤我用了各種辦法無法解決,無奈把my.cnf的名稱變回來:

***@***-VirtualBox:/etc$ sudo mv /etc/my.cnf.old  /etc/my.cnf
####################################################################



解決方法:

檢視錯誤日誌,定位到日誌最後幾行:***@***-VirtualBox:/usr/local/mysql$ more ./data/***-VirtualBox.err

 

##### 日誌內容  start #####

140928 08:52:32 mysqld_safe mysqld from pid file /usr/local/mysql/data/ga

oyu-VirtualBox.pid ended

140928 10:53:01 mysqld_safe Starting mysqld daemon with databases from /u

sr/local/mysql/data

140928 10:53:01 [Note] Plugin 'FEDERATED' is disabled.

140928 10:53:01 InnoDB: The InnoDB memory heap is disabled

140928 10:53:01 InnoDB: Mutexes and rw_locks use InnoDB's own implementat

ion

140928 10:53:01 InnoDB: Compressed tables use zlib 1.2.3

140928 10:53:01 InnoDB: Using Linux native AIO

140928 10:53:01 InnoDB: Initializing buffer pool, size = 128.0M

140928 10:53:01 InnoDB: Completed initialization of buffer pool

140928 10:53:01 InnoDB: highest supported file format is Barracuda.

140928 10:53:01  InnoDB: Waiting for the background threads to start

140928 10:53:02 InnoDB: 5.5.39 started; log sequence number 44664632

140928 10:53:02 [ERROR] /usr/local/mysql/bin/mysqld: unknown variable 'de

fault-character-set=utf8'

140928 10:53:02 [ERROR] Aborting







140928 10:53:02  InnoDB: Starting shutdown...

140928 10:53:03  InnoDB: Shutdown completed; log sequence number 44664632

140928 10:53:03 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete


140928 10:53:03 mysqld_safe mysqld from pid file /usr/local/mysql/data/ga

oyu-VirtualBox.pid ended

 

##### 日誌內容  end #####   

 

 

記得自己為了解決同事的字元編碼問題,把自己機器上面的配置檔案修改過:修改了/etc/my.cnf裡面的【mysqld】的字元設定,在修改回來,試試看,修改方法如下:

把 [client] [mysqld] [mysql]裡面的  default-character-set=utf8 都註釋掉


發現好使了,可以成功登陸MySQL了。

***@***-VirtualBox:/usr/local/mysql$ sudo /etc/init.d/mysql.server start

Starting MySQL

.... * 

***@***-VirtualBox:/usr/local/mysql$ sudo mysql -u root -p

Enter password: 

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.5.39-log MySQL Community Server (GPL)

 

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

 

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

mysql> 

 



來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26435490/viewspace-1283327/,如需轉載,請註明出處,否則將追究法律責任。

相關文章