Is there any reason not to add CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS on mysql connection in mysql_real_connect. http://dev.mysql.com/doc/refman/5.6/en/password-expiration-sandbox-mode.html