Probable update error to mysql 5.7.21
You must be operating in some restricted mode

The MySQL Documentation for ALTER USER says the following:


  Password expiration for an account affects the corresponding row of the mysql.user system table: The server sets the password_expired column to 'Y'.
  
  A client session operates in restricted mode if the account password has been expired. In restricted mode, operations performed within the session result in an error until the user establishes a new account password: 

mysql&gt; SELECT 1;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

mysql&gt; SET PASSWORD = PASSWORD('new_password');
Query OK, 0 rows affected (0.01 sec)

mysql&gt; SELECT 1;
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)



SUGGESTION : Try the aforementioned code

mysql&gt; SET PASSWORD = PASSWORD('new_password');


If this does not works due to old_passwords, do the hash algorithm manually

mysql&gt; SET PASSWORD = CONCAT('*',UPPER(SHA1(UNHEX(SHA1('new_password')))));


I learned about this hash algorithm from PalominoDB (last bought by Pythian).