Method: 1. Use the "RENAME USER" statement to modify the user name, the syntax is "RENAME USER old user name TO new user name"; 2. Use the "SET PASSWORD" statement to modify the user password, the syntax is "SET PASSWORD=PASSWORD (new user password)".
The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.
How to modify mysql user
Modify user account
You can use the RENAME USER statement to modify one Or multiple existing MySQL user accounts.
Syntax format:
RENAME USER <旧用户> TO <新用户>
The syntax description is as follows:
You should pay attention to the following points when using the RENAME USER statement:
The RENAME USER statement is used to rename the original MySQL account.
To use the RENAME USER statement, you must have UPDATE permission on the MySQL database in MySQL or global CREATE USER permission.
Use the RENAME USER statement to change the user name james to jack, and the host is localhost. The input SQL statement and execution process are as follows.
mysql> RENAME USER james@'localhost' -> TO jack@'localhost'; Query OK, 0 rows affected (0.03 sec)
In the Windows command line tool, use jack and password tiger to log in to the database server, as shown below.
C:\Users\USER>mysql -h localhost -u jack -p Enter password: ***** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 7 Server 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 its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
You can use the SET PASSWORD statement to modify a user's login password.
[test_user_new2] is the new password
set password=password('test_user_new2');
Recommended learning: mysql video tutorial
The above is the detailed content of How to modify user in mysql. For more information, please follow other related articles on the PHP Chinese website!