Improve the mysql connection code.

Signed-off-by: Thiago Farina <tfarina@chromium.org>