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