First we want to enter your MySQL server, use net stop mysql to stop MySQL, and then run the DOS command, enter CMD in the run, and then switch to the MySQL bin directory, run the command:
The code is as follows |
Copy Code |
Mysqld--defaults-file= "C:\Program files\mysql\mysql Server 5.1\my.ini"--console--skip-grant-tables |
Now open a CMD window again
The code is as follows |
Copy Code |
Enter command: Mysql-uroot-p Appear: Enter Password: |
Enter directly in here without entering the password.
Then there will be information about the success of the login,
To use the command:
The code is as follows |
Copy Code |
show databases;
|
To switch to the MySQL database using a command:
The code is as follows |
Copy Code |
Use MySQL; |
To change the root password by using the command:
The code is as follows |
Copy Code |
UPDATE user SET Password=password (' NewPassword ') where user= ' root '; |
Refresh permissions:
The code is as follows |
Copy Code |
FLUSH privileges; |
Then exit and log back in:
The code is as follows |
Copy Code |
Quit |
Login again:
The code is as follows |
Copy Code |
Mysql-uroot-p |
Enter a password prompt and enter a new password to sign in:
The code is as follows |
Copy Code |
Enter Password: *********** |
Show Login information: Success it's all OK.
Another way is not directly into your MySQL security mode, is in the MySQL bin directory run mysqld-nt--skip-grant-tables and then the same as the following switch to the MySQL database to update on it.