mysql - 似乎解决了,但为什么呢?当通过一些 SSH 会话连接到远程 mysql 时,它总是在大约 5 分钟 ~ 10 分钟空闲时失去连接
问题描述
我有一个远程 MySQL 服务器。虽然超时变量是 8 小时。它将在大约 10 分钟后断开连接。如下。(当出现断开连接的提示时,有铃声。)
$ mysql -hxxx.xxx.xxx.xxx -uxxxxx -p -A
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 35
Server version: 5.7.19-log MySQL Community Server (GPL)
Copyright (c) 2000, 2020, 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> show global variables like '%timeout';
+-----------------------------+----------+
| Variable_name | Value |
+-----------------------------+----------+
| connect_timeout | 10 |
| delayed_insert_timeout | 300 |
| have_statement_timeout | YES |
| innodb_flush_log_at_timeout | 1 |
| innodb_lock_wait_timeout | 50 |
| innodb_rollback_on_timeout | OFF |
| interactive_timeout | 28800 |
| lock_wait_timeout | 31536000 |
| net_read_timeout | 30 |
| net_write_timeout | 60 |
| rpl_stop_slave_timeout | 31536000 |
| slave_net_timeout | 60 |
| wait_timeout | 28800 |
+-----------------------------+----------+
13 rows in set (0.02 sec)
mysql> show variables like '%timeout';
+-----------------------------+----------+
| Variable_name | Value |
+-----------------------------+----------+
| connect_timeout | 10 |
| delayed_insert_timeout | 300 |
| have_statement_timeout | YES |
| innodb_flush_log_at_timeout | 1 |
| innodb_lock_wait_timeout | 50 |
| innodb_rollback_on_timeout | OFF |
| interactive_timeout | 28800 |
| lock_wait_timeout | 31536000 |
| net_read_timeout | 30 |
| net_write_timeout | 60 |
| rpl_stop_slave_timeout | 31536000 |
| slave_net_timeout | 60 |
| wait_timeout | 28800 |
+-----------------------------+----------+
13 rows in set (0.01 sec)
mysql> show databases;
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> show databases;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 597
Current database: *** NONE ***
+--------------------+
| Database |
+--------------------+
| information_schema |
| xxxxxxx |
| xxxxxxx |
+--------------------+
3 rows in set (0.15 sec)
更新:感谢@scaisEdge 的建议。我发现了奇怪的事情:
如果我以这种方式连接它,我会遇到这个问题:(1)通过 Windows 7 上的 SecureCRT SSH 到这个 Windows 7 上的 VMWare VM CentOS 7.3(2)mysql -hxxx.xxx.xxx.xxx -uxxxxx -p -A
如果我以这种方式连接它,问题就会消失:(1)通过 Windows 7 上的 SecureCRT SSH 到此 Windows 7 上的 VMWare VM CentOS 7.3(2)ssh xxx@xxx.xxx.xxx.xxx(3)mysql -hxxx。 xxx.xxx.xxx -uxxxxx -p -A
当然,我可以将步骤(3)改为: MySQL -h127.0.0.1 -uxxxxx -p -A
注意:我跳几次的原因是Windows平台上的MySQL CLI客户端不如Linux上的好。
虽然好像解决了,但是很奇怪。为什么?
有高手能给我一些建议吗?非常感谢!
解决方案
推荐阅读
- php - 找不到 DB Seeder 类
- visual-c++ - 如何通过 CPUID 命令使用 C/C++ 获取物理和虚拟地址位
- java - 如何更改android中按钮的背景?
- quickbase - Quickbase API 调用的问题
- c++ - 为什么使用 vecS 作为 OutEdgeList 模板参数的 boost adjacency_list 在遍历时会使边无效?
- google-cloud-platform - 云文档 AI 无法处理存储中的文档
- python - 如何迭代按子字典中的元素排序的字典?
- c++ - 没有模板参数的类模板值错误
- python - 如何让多个 MLFlow 并行运行?
- python - For/in 函数打印所有变量(在同一行),而不是 python 中的一个。解决方案?