2016-03-03 32 views
1

我有一個mont前安裝mysql。我每天使用都沒有任何問題。現在,我的mysql很奇怪。我可以登錄到MySQL,並一直成功。但有時無法運行查詢。本地Mysql成功登錄,但丟失連接每次運行查詢

這是unseccessfull查詢的示例:

[email protected] ~ $ mysql -uroot -p 
Enter password: 
Welcome to the MySQL monitor. Commands end with ; or \g. 
Your MySQL connection id is 3 
Server version: 5.5.47-0ubuntu0.14.04.1 (Ubuntu) 

Copyright (c) 2000, 2015, 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> use sps; 
Reading table information for completion of table and column names 
You can turn off this feature to get a quicker startup with -A 

Database changed 
mysql> show databases; 
ERROR 2006 (HY000): MySQL server has gone away 
No connection. Trying to reconnect... 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) 
ERROR: 
Can't connect to the server 

mysql> 

我很迷茫。如何解決這個問題呢?

+0

沒有人希望備份...每個人都想恢復... – ratmalwer

回答

0

這是一個常見問題,最大的原因通常只是超時問題,在大量空閒時間之後會出現此錯誤嗎?

如果該命令返回的數據量過大,也會導致該問題。

列出了各種原因和修復程序HERE請嘗試修復,如果您仍有問題,請告訴我們您已經嘗試過的。

+0

我的數據非常小。允許的最大數據包設置爲500M(僅用於調試)。我不需要大數據查詢。就像「顯示錶格」和簡單的選擇查詢一樣。簡單的查詢有時會成功,有時會因錯誤連接而失敗。我使用mysq-client在同一臺機器上運行查詢。對於這種情況,我認爲我的原因問題沒有列出。 – mosleim

+0

您是在本地訪問託管服務器還是通過網絡訪問服務器?您是否嘗試啓用文章中提到的日誌記錄級別以啓用服務器上某些註銷消息的捕獲? – Nick

+0

我在本地訪問。 – mosleim

相關問題