Make sure MySQL is connected before running operations. Fixes #1