Added reconnect to mysql

@chirimoya @dantleech Do you have any ideas?