MySQL 8 brought many highly anticipated features, with support for user roles, a new shell, a more robust data dictionary, and better SQL support, just to name a few. There are lesser-known new features, however, that aim to reduce overall DBA workload and streamline management processes – and one of these is support for dual passwords, first implemented in MySQL 8.0.14. User accounts are now permitted to have dual passwords, with a designated primary and secondary. This makes it possible to seamlessly perform user credential changes even with a large number of servers, or with multiple applications connecting to different MySQL servers.
Historically, a MySQL credential change had to be timed so that when the password change was made and propagated throughout the database nodes, all applications that use that account for connections had to be updated at the same time. This is problematic for many reasons, but with database and application server counts as high as they are today, it becomes especially burdensome at the modern enterprise scale.
With dual passwords, credential changes can be made easily without requiring any coordination or downtime. The process would work something like this:
To accomplish this dual password capability, the following new syntax will save and discard secondary passwords:
As an example, let’s use the dual password feature to update the password for a theoretical user (‘appuser’@’percona.com’). For this example, assume that application(s) will connect to the database with this user and that we will be changing the password from ‘oldpass’ to ‘newpass’.
|
1 |
mysql> ALTER USER 'appuser'@'percona.com' IDENTIFIED BY 'newpass' RETAIN CURRENT PASSWORD; |
|
1 |
mysql> ALTER USER 'appuser'@'percona.com' DISCARD OLD PASSWORD; |
There are a few caveats you may want to be aware of in using the dual password feature:
For modifying your own user account(s), the APPLICATION PASSWORD ADMIN privilege is required in order to use RETAIN CURRENT PASSWORD or DISCARD OLD PASSWORD clause for both the ALTER USER and SET PASSWORD statements.
For modifying the secondary password for any (or all) accounts at an administrative level, the CREATE USER privilege is needed rather than the APPLICATION PASSWORD ADMIN privilege as above.
While this is a very simple new feature, it can have a fairly significant impact on how your company manages the security aspects of frequent password changes, minimizing or possibly eliminating downtime from password updates altogether.
Percona Distribution for MySQL is the most complete, stable, scalable, and secure, open-source MySQL solution available, delivering enterprise-grade database environments for your most critical business applications… and it’s free to use!