似乎解决了,但为什么?当通过一些SSH会话连接到远程mysql时,它总是在大约5分钟~10分钟的空闲时间内失去连接

似乎解决了,但为什么?当通过一些SSH会话连接到远程mysql时,它总是在大约5分钟~10分钟的空闲时间内失去连接,mysql,timeout,Mysql,Timeout,我有一个远程MySQL服务器。虽然超时变量为8小时。它将在大约10分钟内失去连接。如下。(当出现断开提示时,有铃声) 更新: 感谢@scaisEdge的建议。我发现了一件奇怪的事: 如果以这种方式连接,我会遇到此问题: (1) 通过Windows 7上的SecureCRT将SSH连接到此Windows 7上的VMWare VM CentOS 7.3 (2) mysql-hxxx.xxx.xxx.xxx-uxxx-p-A 如果我这样连接它,问题就会消失: (1) 通过Windows 7上的Secu

我有一个远程MySQL服务器。虽然超时变量为8小时。它将在大约10分钟内失去连接。如下。(当出现断开提示时,有铃声)

更新: 感谢@scaisEdge的建议。我发现了一件奇怪的事:

如果以这种方式连接,我会遇到此问题: (1) 通过Windows 7上的SecureCRT将SSH连接到此Windows 7上的VMWare VM CentOS 7.3 (2) mysql-hxxx.xxx.xxx.xxx-uxxx-p-A

如果我这样连接它,问题就会消失: (1) 通过Windows 7上的SecureCRT将SSH连接到此Windows 7上的VMWare VM CentOS 7.3 (2) sshxxx@xxx.xxx.xxx.xxx (3) mysql-hxxx.xxx.xxx.xxx-uxxx-p-A

当然,我可以将步骤(3)更改为: MySQL-h127.0.0.1-uxxx-p-A

注意:我多次跳转的原因是Windows平台上的MySQL CLI客户端不如Linux平台上的好

虽然这似乎已经解决了,但很奇怪。为什么?


有专家能给我一些建议吗?非常感谢

您是否通过网络服务器连接???您好@scaisEdge,这是来自中国阿里云的云服务器。我的意思是MySQL服务器位于阿里云的云服务器(CentOS 7.3)上。我将其从Windows 7 SecureCRT上的SSH会话连接到Windows 7系统内的VMWare VM(CentOS 7.3)。您确定会话超时吗?对不起,英语不是我的母语,我不确定“您确定…”。我的意思是,如果它空闲大约5分钟~10分钟,我肯定会丢失它。您还应该检查Windows 7 SecureCRT上的SSH会话是否存在超时
$ 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)