Several methods of modifying database password with MySQL
The first way:
The simplest method is to modify with the help of the third-party tool Navicat for MySQL, as follows:
1. Log in MySQL to the specified library, for example, log in to the test library.
2. Then click the "user" button above.
3. Select the user name to be changed, and then click the "edit user" button above.
4. The interface as shown in the figure appears, enter the new password, confirm the new password, and click the "save" button.
The second way:
Method 1: use the set password command
Log in to MySQL first.
Format: MySQL > set password for username @ localhost = password ('New password ');
Example: MySQL > set password for root@localhost = password('123');
Method 2: use mysqladmin
Format: mysqladmin - U username - P old password password new password
Example: mysqladmin - uroot - p123456 password 123
Method 3: directly edit the user table with update
First log in to MySQL.
MysqL> use MysqL;
MysqL> update user set password=password('123') where user='root' and host='localhost';
MysqL> flush privileges;
Method 4: when forgetting the root password, you can do this
Take windows as an example:
1. Close the running MySQL service.
2. Open the DOS window and go to the MySQL \ bin directory.
3. Enter mysqld -- skip grant tables and press enter-- Skip grant tables means to skip the permission table authentication when starting the MySQL service.
4. Open another DOS window (because the DOS window just now can't move), and go to the MySQL \ bin directory.
5. Enter mysql. If successful, the MySQL prompt > will appear.
6. Connect to the permission database: use MySQL.
6. Change Password: update user set password = password ("123") where user = "root"; Don't forget to add a semicolon at the end.
7. Refresh permissions (required steps): flush privileges.
8. Quit quit.
9. Log out of the system, enter again, and log in with the user name root and the new password 123 just set.
The third way: