Since version 5.6.6 the MySQL server supports password expiration.
Client applications needs an option to indicate, that they are able to handle expired passwords.
This happens by setting the client_capability CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS. If this capability is set, the server switches to a sandbox mode, in which a new password needs to be defined.
The capability will be set/unset via mysql_optionsv():