Backup the username and password in MySQL

Script for generating user password backup in MySQL

The use of password backup is for refresh activity or need to save some time Application user password because the application is configured on that password.

Note: Authentication_String is used from MySQL 5.7 upper version before Password is used.

SELECT CONCAT('CREATE USER \'', user, '\'@\'', host, '\' IDENTIFIED by \'', authentication_string,'\';') FROM mysql.user;

-----------+
| CREATE USER 'mysql.infoschema'@'localhost' IDENTIFIED by '$A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED'; |
| CREATE USER 'mysql.session'@'localhost' IDENTIFIED by '$A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED';    |
| CREATE USER 'mysql.sys'@'localhost' IDENTIFIED by '$A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED';        |
| CREATE USER 'mysqlbackup'@'localhost' IDENTIFIED by '$A$005$9hPgSV\hH}7]i]Avdhnu/4FWSpfRmZD4NXpZWa/N9cm2Xjslbi9N6oxKJ6';|

Use this by modified by ALTER command:

mysql> ALTER USER 'mysqlbackup'@'localhost' IDENTIFIED by '$A$005$9hPgSV\hH}7^^]i^C^V]A^Zvdhnu/4FWSpfRmZD4NXpZWa/N9cm2Xjslbi9N6oxKJ6';
Query OK, 0 rows affected (0.03 sec)

1 thought on “Backup the username and password in MySQL

  1. Pingback: Change Password for User in MySQL database | Smart way of Technology

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.