Take a backup of the user password in MariaDB / MySQL
Take a backup of the user with an encrypted password.
Save this user’s encrypted password, which will be used again to set the password.
MariaDB [(none)]> select user,password,host from mysql.user;
+-------------+-------------------------------------------+----------------+
| User | Password | Host |
+-------------+-------------------------------------------+----------------+
| mariadb.sys | | localhost |
| root | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 | localhost |
| TEST1 | *06C0BF5B64ECE2F648B5F048A71903906BA08E5C | % |
| TEST | *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29 | % |
| user1 | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 | % |
+-------------+-------------------------------------------+----------------+
5 rows in set (0.001 sec)
Alter the command to use the encrypted password
ALTER USER user1@'%' identified by password '******';
Example:
MariaDB [(none)]> alter user TEST@'%' identified by password '*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19';
Query OK, 0 rows affected (0.010 sec)
Change the password of TEST user and use the encrypted password of user1 and connect with TEST user:
MariaDB [(none)]> select user,password,host from mysql.user;
+-------------+-------------------------------------------+----------------+
| User | Password | Host |
+-------------+-------------------------------------------+----------------+
| mariadb.sys | | localhost |
| root | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 | localhost |
| TEST1 | *06C0BF5B64ECE2F648B5F048A71903906BA08E5C | % |
| TEST | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 | % |
| user1 | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 | % |
+-------------+-------------------------------------------+----------------+
5 rows in set (0.001 sec)
C:\WINDOWS\System32>mysql -u TEST -p
Enter password: ********
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 10.6.5-MariaDB mariadb.org binary distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
MariaDB [(none)]>