Check return code of mysql_init()

Fixes #1908