Expired password mysql

If you are running mysql 5.7.4 or later all user password will expire after 360 days by default!

To change this you can one of the following.

Change the global password expiration setting to never expire passwords:


mysql -u root -p
mysql> show global variables like 'default_password_lifetime';
+---------------------------+-------+
| Variable_name | Value |
+---------------------------+-------+
| default_password_lifetime | 360 |
+---------------------------+-------+
1 row in set (0.00 sec) mysql> set global default_password_lifetime=0;
Query OK, 0 rows affected (0.00 sec)< mysql> show global variables like 'default_password_lifetime';
+---------------------------+-------+
| Variable_name | Value |
+---------------------------+-------+
| default_password_lifetime | 0 |
+---------------------------+-------+
1 row in set (0.00 sec) mysql>

Set password expiration on a single user:

mysql -u root -p

ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER


Change global password expiration in my.cnf, this required mysql restart.

[mysqld]
default_password_lifetime=0

 

If your password already expired you need to set a new password first. You can set the same password again just to reset the password expiration.

ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

mysql> SET PASSWORD FOR 'root'@'%' = PASSWORD('mypassword');

 

Or if you are doing this on the database node.

ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('mypassword');

Was this article helpful?
1 out of 1 found this helpful
Have more questions? Submit a request

Comments

0 comments

Article is closed for comments.