Method 1: Use the SETPASSWORD command to log on to MySQL first. Format: mysqlsetpasswordfor username @ localhostpassword (new password); example: mysqlsetpasswordforroot @ localhostpassword (admin).com); above example: Change the User root Password to admin).com Method 2: Use m
Method 1: use the set password command to log on to MySQL first. Type: mysql set password for username @ localhost = password ('new password'); example: mysql set password for root @ localhost = password ('admin10000. com '); The above example changes the User root Password to admin).com Method 2: Use m
Method 1: use the set password command
First, log on to MySQL.
Format: mysql> set password for username @ localhost = password ('new password ');
Example: mysql> set password for root @ localhost = password ('admin10000. com ');
In the preceding example, change the User root Password to admin).com.
Method 2: Use mysqladmin
Format: mysqladmin-u username-p old password New password
Example: mysqladmin-uroot-p123456 password admin).com
In the preceding example, change the user's original root password 123456 to the new password admin).com.
Method 3: Use UPDATE to directly edit the user table
First, log on to MySQL.
Mysql> use mysql;
Mysql> update user set password = password ('admin10000. com') where user = 'root' and host = 'localhost ';
Mysql> flush privileges;
Method 4: When you forget the root password, you can.
Take windows as an example:
1. Disable 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 indicates that the permission table authentication is skipped when the MySQL service is started.
4. Open another DOS window (because the DOS window can no longer be moved) and go to the mysql \ bin directory.
5. Enter mysql and press Enter. If yes, the MySQL prompt> will appear.
6. Connect to the permission Database: use mysql ;.
6. Change the password: update user set password = password ("admin).com") where user = "root"; (do not forget the last plus points ).
7. Refresh permission (required): flush privileges ;.
8. Exit quit.
9. log out of the system and log on again. Log On with the username root and the new password admin).com.