DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

(mysql.info) mysql-reconnect

Info Catalog (mysql.info) safe-updates (mysql.info) mysql-tips
 
 8.5.4.3 Disabling `mysql' Auto-Reconnect
 ........................................
 
 If the `mysql' client loses its connection to the server while sending
 a query, it immediately and automatically tries to reconnect once to
 the server and send the query again. However, even if `mysql' succeeds
 in reconnecting, your first connection has ended and all your previous
 session objects and settings are lost: temporary tables, the autocommit
 mode, and user-defined and session variables. Also, any current
 transaction rolls back.  This behavior may be dangerous for you, as in
 the following example where the server was shut down and restarted
 without you knowing it:
 
      mysql> SET @a=1;
      Query OK, 0 rows affected (0.05 sec)
 
      mysql> INSERT INTO t VALUES(@a);
      ERROR 2006: MySQL server has gone away
      No connection. Trying to reconnect...
      Connection id:    1
      Current database: test
 
      Query OK, 1 row affected (1.30 sec)
 
      mysql> SELECT * FROM t;
      +------+
      | a    |
      +------+
      | NULL |
      +------+
      1 row in set (0.05 sec)
 
 The `@a' user variable has been lost with the connection, and after the
 reconnection it is undefined.  If it is important to have `mysql'
 terminate with an error if the connection has been lost, you can start
 the `mysql' client with the -skip-reconnect option.
 
Info Catalog (mysql.info) safe-updates (mysql.info) mysql-tips
automatically generated byinfo2html