Modify the username and password of the Mysql database [detailed]

The database user name is root by default

1 into Mysql

        First log in to the database

        1win+r, enter cmd [ open as administrator ] or 2search and enter the command prompt.

2 Enter mysql -uroot -p and press Enter

        Note: mysql default user name is root , I changed it before, so I entered mysql -uerp -p and press Enter , then enter the password.

        mysql -h hostname -u username -p

Go to the Mysql success page.

 3 and then entered into mysql

        Enter select user from mysql.user; you can query all existing user names in mysql

 (1) Modify the Mysql username

Enter the following statement to enter the database

use mysql

Then enter update user set user = 'new username' where user = 'old username' , for example:

update user set user =’user’ where user =’erp’;

 Then call select user from mysql.user again; check whether the modification is successful.

The most important step: Refresh permissions .

Execute flush privileges;

 

(2) Modify the login password of the Mysql database

Note: still follow the above steps to enter mysql

Execute the command

alter user 'user'@'localhost' identified by 'newpassword';

Among them, erp is the username of mysql, usually root, I changed it to user, and newpassword is the password you want to change.

 

 Refresh permissions, execute flush privileges ;

expand:

MySQL database--command line operation

Guess you like

Origin blog.csdn.net/m0_64210833/article/details/127548869