mysql - 本地Mysql成功登录,但每次运行查询都失去连接

标签 mysql

我在一个月前安装了 mysql。我每天都使用没有任何问题。而现在,我的mysql很奇怪。我可以登录到mysql,并且总是成功。但是,有时无法运行查询。

这是 unseccessfull 查询的示例:

gai@gai-Lenovo-G470 ~ $ 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> 

我很困惑。如何解决这个问题?

最佳答案

这是一个常见问题,最大的原因通常只是超时问题,大量空闲时间后会出现此错误吗?

如果命令返回的数据量过大,也可能导致问题。

列出了各种原因和修复方法 HERE请尝试修复,如果您仍然遇到问题,请告诉我们您尝试了什么。

关于mysql - 本地Mysql成功登录,但每次运行查询都失去连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35762174/

相关文章:

mysql - 为什么我们将一个mysql表分成许多较小的表?

php - Mysql DELETE查询异常行为

mysql - 使用外键从多个表插入数据

java - java中的列名无效,但适用于数据库

带有salt的MySQL encrypt()在密码后接受随机字符

php - uksort 帮助 - 在单个需要帮助中使用 GROUP BY

mysql - 需要帮助进行玩家评分计算的数据库/查询设计

php - 打印 mysqli SELECT 查询的结果

php - CakePHP:向日期字段添加天数并在查找查询中比较它们

mysql - sync_binlog参数