Expired password for MySQL 5.7.4 to 5.7.10
The limited password life problem only occurs for versions of MySQL between 5.7.4 and 5.7.10 included (*):
Excerpt from
documentation MySQLFrom MySQL 5.7.4 to 5.7.10, the default default_password_lifetime value is 360 (passwords must be changed approximately once per year). For those versions, be aware that, if you make no changes to the default_password_lifetime variable or to individual user accounts, all user passwords will expire after 360 days, and all user accounts will start running in restricted mode when this happens. Clients (which are effectively users) connecting to the server will then get an error indicating that the password must be changed: ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.This is due to the behavior of the variable "default_password_lifetime" which by default (that is even if it does not exist in the my.ini file) is:
- from MySQL 5.7.4 to 5.7.10 inclusive: 360 is a year
- from MySQL 5.7.11: 0 is no limitation
When the password is expired, we have error:
#1862 - Your password has expired. To log in you must change it using a client that supports expired passwords.
mysqli_real_connect(): (HY000/1862): Your password has expired. To log in you must change it using a client that supports expired passwords.
We will be able to give a new password to root and to do this, we will use the MySQL Console.
- Open MySQL Console
Left-Click Wampmanager tray icon -> MySQL -> MySQL Console
At the prompt Enter password: just type Enter key.
We will now assign a new password to root, even if there were none before.
- In the MySQL Console, type (With Enter key at the end):
--- Note : Replace newpassword by the password you want.
--- This can be the same password that you had before.
mysql> ALTER USER USER() IDENTIFIED BY 'newpassword';
Query OK, 0 rows affected (0.00 sec)
Then, still in the MySQL console do not set the password to a period of validity:
mysql> ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.00 sec)
Exit the MySQL console
(*) For MySQL versions after 5.7.10 (So from 5.7.11), it is necessary to explicitly declare a lifetime of the passwords, otherwise there is no limitation.
Edited 1 time(s). Last edit at 01/11/2021 11:15AM by Otomatic.