mysql Modify the root user password (you can also modify the password if you forget it)

Method 1: Log in to MySQL first  with the SET PASSWORD command . 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: Edit the user table directly 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 you forget the root password, you can use windows like this For example: 1. Shut down the running MySQL service. 2. Open a DOS window and go to the mysql\bin directory. 3. Type mysqld --skip-grant-tables and press Enter. --skip-grant-tables means to skip permission table authentication when starting the MySQL service. 4.  




 



 





 
 




5. Type mysql and press Enter. If successful, the MySQL prompt > will appear. 
6. Connect to the permission database: use mysql; . 
6. Change the password: update user set password=password("123") where user="root"; (don't forget to add a semicolon at the end). 
7. Refresh privileges (required step): flush privileges; . 
8. Exit quit. 
9. Log out of the system, log in again, and log in with the username root and the new password 123 just set.

 

 

 

Source: http://www.jb51.net/article/39454.htm

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326099940&siteId=291194637