Skip to content

Rate this page
☆ ☆ ☆ ☆ ☆
Thanks for your feedback
Thank you! The feedback has been submitted.

Get free database assistance or contact our experts for personalized support.

MySQL automatic password expiration

The mysql_automatic_expired_password check warns if MySQL doesn’t expire passwords automatically, or if the password lifetime is too long.

Description

The default_password_lifetime system variable sets the global automatic password expiration policy: the number of days after which passwords expire. The default value, 0, disables automatic expiration, so passwords never expire unless you expire them manually. Passwords that never change are more likely to be leaked and reused in an attack on the database.

The check reads the server variables and returns a warning if default_password_lifetime is:

  • 0: Automatic password expiration is inactive.
  • 365 or more: The password lifetime is too long.

The warning also shows the disconnect_on_expired_password setting, which controls how the server treats clients whose password expired. If the variable is ON, the default, the server disconnects clients that can’t handle expired passwords. If it is OFF, the server puts them in sandbox mode, where they can only reset the password.

Resolution

Set default_password_lifetime to a positive number of days that is less than 365, for example:

SET PERSIST default_password_lifetime = 180;

SET PERSIST applies the value right away and keeps it after a restart. On MySQL 5.7, run SET GLOBAL instead, and add the setting to the [mysqld] section of the configuration file.

To set a different lifetime for a specific account, use ALTER USER:

ALTER USER 'app'@'10.0.1.15' PASSWORD EXPIRE INTERVAL 90 DAY;

To choose a policy for your accounts, read how the MySQL password expiration policy works and how the server handles expired passwords.

Need more support from Percona?

Percona experts bring years of experience in tackling tough database performance issues and design challenges.