Mysql – Disabling password change for a MySQL user

MySQLpermissionsusers

Is it possible for MySQL users to prevent/disable changing their password with just the USAGE option? There are no global permissions allowed.
I tried to google, but had no luck.

Best Answer

One way to achieve this could be by using pluggable authentication. This way the password is stored externally and therefore can't be changed from within mysql. This allows you to use PAM, LDAP or other authentication services.

For PAM, assuming you have configured PAM already in your OS (assuming Linux below), then in MySQL do:

INSTALL PLUGIN authentication_pam SONAME 'authentication_pam.so';
CREATE USER bob@'%' IDENTIFIED WITH authentication_pam AS 'mysql'; 

... where AS 'mysql' refers to a file /etc/pam.d/mysql.

If the user then tries to set their password (I've tested this only on MariaDB with the unix_socket plugin):

SET PASSWORD = PASSWORD('My_very_clever_password');

... that query will "work", however it gives a warning:

SET PASSWORD has no significance for users authenticating via plugins