1, to root add a password pass123:
First enter the directory Mysqlbin in DOS, and then type the following command
The code is as follows |
Copy Code |
Mysqladmin-u Root-password pass123 |
Note: Since Root does not have a password at the beginning, the-p old password can be omitted.
2. Change the password of root to pass456.
The code is as follows |
Copy Code |
Mysqladmin-u root-p pass123 Password pass456 |
The above two are the commands entered in the CMD command line, so direct return is OK.
The following is a description of the commands in the MySQL environment, with a semicolon as the command terminator at the end of the MySQL command.
3, the command line to modify the root password:
The code is as follows |
Copy Code |
mysql> UPDATE mysql.user SET password=password (' newpassword ') WHERE user= ' root '; |
After running this line, you will be prompted with the following information:
The code is as follows |
Copy Code |
Query OK, 0 rows Affected (0.00 sec) Rows matched:2 changed:0 warnings:0 |
This time you need to run the following sentence, otherwise the password will not be modified:
The code is as follows |
Copy Code |
mysql> FLUSH privileges; |
The following run results represent the successful modification:
Query OK, 0 rows affected (0.16 sec)
4, display the current user:
The code is as follows |
Copy Code |
Mysql> SELECT USER (); |