Switch from MySQL to MySQLi

Also adds MySQLi unit tests.