Neo's Blog

首頁 相本 討論 書籤

分類目錄
本站日誌 (51)
碎碎唸啦 (173)
網站架設 (84)
程式設計 (161)
軟體使用 (69)
電子商務 (126)
經營奇想 (48)
基金理財 (11)
聰明消費 (87)
電影心得 (47)
開放原碼 (16)
工作記錄 (2)
毛毛小記 (9)
就是不同 (2)




歷史資料
 




March 16, 2004
發生找不到 mysql.sock 的處理方法!

出現以下的訊息:


Got an error: Connection error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

mysql.sock 突然消失算是常見的問題,如果是第一次安裝MySQL才出現,那只要找出 mysql.sock 在哪裡就可以了。

以上述的錯誤訊息,mysql.sock 應該是在 /var/lib/mysql/ 裡面 ,如果沒有的話,就下:


#find / -name mysql.sock


來找看看放在哪裡,找到之後再下:

#mysqladmin -S /找到路徑/mysql.sock -u root {參數}

那...如果是突然不見的,或是都找不到怎麼辦?

那只好重新啟動 mysql 了,tarball 安裝可以透過 mysqld 或 mysqladmin 重新啟動,rpm 安裝可以透過 service mysql restart 。但是在 mysql.sock 不見的情況下,可能是無法重新啟動 mysql 的,如果真的不行,只好先下:

#ps -aux|grep mysql

再把看到的 pid 先砍了

#kill 看到的pid

確定全部都殺完了,再看一次還有沒有

#ps -aux|grep mysql

確定裡面的 mysql 都沒有了,然後再執行 mysqld 或是 service mysql start 就可以了。

 
由 Neo 發表於 March 16, 2004 10:12 AM 收進你的MyShare個人書籤  

小弟不解,mysql.sock 突然消失算是常見的問題,是什麼狀況會讓他消失,因為最近我家的Server常出現這類的問題,希望能得到一些solution,謝謝


herzog 發表於 July 8, 2005 01:56 PM

會突然消失的狀況我只出現過幾次,你可以用 Google 查看看有沒有答案。


Neo 發表於 July 11, 2005 12:49 AM

我有一個問題,
是在 mysql 啟動後,
儲存 pid 的那個檔案大小是 0
也就是說 pid 沒有寫入。
在想要關閉 mysql 時只能使用 kill -9 的方法,
請問是否有方法解決。


giengin 發表於 September 21, 2005 11:15 AM

奇怪啊...為什麼我裝起來時會沒有mysql.sock啊...是不是少裝什麼,我是Fedora3


帝釋天 發表於 November 16, 2005 09:42 PM

我的系统是fc7,装的时候是全装了,用mysql时提示:
mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
没有mysql.sock
ps -e也没发现mysql启动
find / -name mysql.sock也没找到不能解决sos help


吴科 發表於 August 28, 2007 12:39 PM

太感谢了,终于用你的方法搞定了!


jytz79 發表於 June 11, 2008 11:36 AM

I can't use this command, cos i don't know how
"#mysqladmin -S /找到路徑/mysql.sock -u root {參數}"
works

but i found we can directly modify the /etc/my.cnf file, just make sure u have the folling lines inside /etc/my.cnf

[mysql]
socket=/tmp/mysql.sock

this will make /tmp/mysql.sock ur default sock file path when u using "mysql -u USER"


AndyChang 發表於 June 23, 2008 11:21 AM
發表迴響  
(*星號開頭為必填欄位)











(請輸入您看到的數字,看不到請按右鍵->顯示圖片)


記住我的資訊?







Copyright 2005 Neo's Blog All rights reserved.