Get the App
SLTechnology News&Howtos  ›  Database  › 

How mysql modifies users

Shulou Source: shulou.com Published: 2022-05-31 11:21:42 09月25日 Update

This article will introduce in detail "mysql how to modify users", the content steps are clear and detailed, the details are handled properly, and the editor updates different knowledge points every day, I hope this article "how to modify users in mysql" can give you unexpected gains, please follow the editor's ideas slowly in depth, the specific content is as follows, together to harvest new knowledge.

Methods: 1, use "RENAME USER" statement to modify user name, syntax is "RENAME USER old user name TO new user name"; 2, use "SET PASSWORD" statement to modify user password, syntax is "SET PASSWORD=PASSWORD (new user password)".

The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.

How mysql modifies users

Modify user account

You can use the RENAME USER statement to modify one or more existing MySQL user accounts.

Syntax format:

RENAME USER TO

The syntax is as follows:

MySQL user account that already exists in the system.

: new MySQL user account.

You should be aware of the following when using RENAME USER statements:

The RENAME USER statement is used to rename the original MySQL account.

If the old account does not exist in the system or the new account already exists, an error will occur during the execution of the statement.

To use the RENAME USER statement, you must have UPDATE permissions or global CREATE USER permissions for the MySQL database in MySQL.

Use the RENAME USER statement to change the user name james to jack and the host to localhost. The SQL statement entered and the execution procedure are shown below.

Mysql > RENAME USER james@'localhost'-> TO jack@'localhost';Query OK, 0 rows affected (0.03 sec)

In the Windows command line tool, log in to the database server using jack and password tiger, as shown below.

C:\ Users\ USER > mysql-h localhost-u jack-pEnter password: * Welcome to the MySQL monitor. Commands end with; or\ g.Your MySQL connection id is 7Server version: 5.7.20-log MySQL Community Server (GPL) Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.

You can use the SET PASSWORD statement to change a user's login password.

[test_user_new2] is the new password

Set password=password ('test_user_new2')

Thank you for reading this. The editor hopes that you have the most profound experience on the key issue of "how to modify users of mysql" from the practical level, and you still need to practice and use it yourself to understand it. If you want to read more related articles, welcome to follow the industry information channel!

Tags: User statement password user name syntax account content system account data database permissions practice login different proper unexpected host global command Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi OPPO Reno vpn NVidia MariaDB