2016-03-03 60 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