Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of modifying user name by MySQL

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail the method of changing the user name of MySQL. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

If the MySQL administrator wants to change the user name or host of an existing MySQL user account without changing the user account privileges, you can use the RENAME USER statement in MySQL.

RENAME USER statement syntax:

RENAME USER 'username'@'host' TO' new_username'@'host'

Parameters:

Username: this is the user name of the user account you want to rename.

New_username: this is the new name you want to assign to the user.

Suppose there are four users in the MySQL database server, as follows:

Now let's see how to rename a user using the RENAME USER statement:

Use the RENAME USER statement to rename a single user:

To rename a user account with the user name "gfguser1", execute the RENAME USER statement as follows:

Syntax:

Output:

The table after executing the renamed user statement is as follows:

Rename multiple users using the RENAME USER statement:

The RENAME USER statement can be used to rename multiple user accounts at a time. To rename the two user accounts "gfguser2" and "gfguser1" in the above table, execute the RENAME USER statement as follows:

Syntax:

Output:

The table after executing the above renamed user statement is as follows:

This is the end of the method of modifying the user name of MySQL. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report