现象:
- mysql服务器本地连接查询没有问题
- 其他服务器连接mysql服务进行查询没有问题
- 公司内部连接到mysql服务无法正常进行查询
- 第一次查询的时候无法查询,第二次查询则成功,第三次查询又失败,第四次则又成功,如此循环,如下:
mysql> show variables like 'max_allowed_packet';
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> show variables like 'max_allowed_packet';
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 4325
Current database: *** NONE ***
+--------------------+---------+
| Variable_name | Value |
+--------------------+---------+
| max_allowed_packet | 4194304 |
+--------------------+---------+
1 row in set (0.07 sec)
mysql>
解决办法:
set global innodb_lock_wait_timeout=500;
结果:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| byex_db_cg |
+--------------------+
2 rows in set (0.01 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| byex_db_cg |
+--------------------+
2 rows in set (0.01 sec)
网友评论