Fix bug with MySQL reconnect code

It wasn't retrying if MySQL server was down or shutting down.