Share

How to rename an existing user on mysql server ?

It is possible to change the name of an existing user on the MySql server later. To do this, you can use the ” rename ” command after connecting to the MySql server with root.

After connecting to the MySQL server via root, the relevant operations must be performed.

mysql -u root -p

Username can be changed as follows.

MariaDB [(none)]> rename user 'test_user'@'%' to 'deneme_user'@'%';
Query OK, 0 rows affected (0.00 sec)

To check if the user’s name has changed, we can query the users in the system as follows.

MariaDB [(none)]> select user, password, host from mysql.user;
+-------------+-------------------------------------------+-----------+
| user        | password                                  | host      |
+-------------+-------------------------------------------+-----------+
| root        | *721D6F5CAD41C9A14E3FE73EAB61B4CD258A1B4B | localhost |
| root        | *721D6F5CAD41C9A14E3FE73EAB61B4CD258A1B4B | mysqldb |
| root        | *721D6F5CAD41C9A14E3FE73EAB61B4CD258A1B4B | 127.0.0.1 |
| root        | *721D6F5CAD41C9A14E3FE73EAB61B4CD258A1B4B | ::1       |
| deneme_user | *540BAABDF215F3E237EAEA9CF23E88D27D054CCE | %         |
+-------------+-------------------------------------------+-----------+
6 rows in set (0.00 sec)

 

Loading

You may also like