禁用 mysql 中远程客户端连接的自动重新连接

禁用 mysql 中远程客户端连接的自动重新连接

我在我的数据库服务器中使用以下版本的 MYSQL。

root@XXXXXX-test-server:~# mysql -V
mysql  Ver 14.14 Distrib 5.6.16, for debian-linux-gnu (x86_64) using  EditLine wrapper
root@XXXXX-test-server:~# 

当我使用 KILL 命令从服务器端关闭远程连接时,它会自动从客户端重新连接。

服务器端:

mysql> 
mysql> show processlist;
+----+-----------+----------------------+------+---------+------+-------+------------------+
| Id | User      | Host                 | db   | Command | Time | State | Info             |
+----+-----------+----------------------+------+---------+------+-------+------------------+
| 37 | test_user | 192.168.47.130:45042 | NULL | Sleep   |   75 |       | NULL             |
| 39 | root      | localhost            | NULL | Query   |    0 | init  | show processlist |
+----+-----------+----------------------+------+---------+------+-------+------------------+
2 rows in set (0.00 sec)

mysql> 
mysql> kill 37;
Query OK, 0 rows affected (0.01 sec)

mysql> 
mysql> show processlist;
+----+------+-----------+------+---------+------+-------+------------------+
| Id | User | Host      | db   | Command | Time | State | Info             |
+----+------+-----------+------+---------+------+-------+------------------+
| 39 | root | localhost | NULL | Query   |    0 | init  | show processlist |
+----+------+-----------+------+---------+------+-------+------------------+
1 row in set (0.00 sec)

mysql> 

客户端:

mysql> 
mysql> show databases;
ERROR 2013 (HY000): Lost connection to MySQL server during query
No connection. Trying to reconnect...
Connection id:    40
Current database: *** NONE ***

+--------------------+
| Database           |
+--------------------+
| information_schema |
+--------------------+
1 row in set (0.01 sec)

mysql> 

如何禁用远程连接的自动重新连接选项?

我尝试在 my.cnf 配置文件的“[client]”部分添加“reconnect=false”。但是没有用。它仍然会自动从客户端重新连接。

相关内容