Automatically reconnect to MySQL server