我在一个月前安装了 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/