Score:0

Disable auto reconnect for remote client connections in mysql

sg flag

I use below version of MYSQL in my DB server.

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:~# 

When I close remote connections from server side using KILL command, it is reconnectiong from client side automatically.

Server side:

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> 

Client Side:

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> 

How do I can disable auto reconnect option for remote connections?

I have tried with adding "reconnect=false" to '[client]' section in my.cnf config file. But it does not work. Still it reconnects from client side automatically.

asktyagi avatar
in flag
What do you see at OS level? add process level details to the question from server and client side.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.