1. The Method of Modifying MySQL Password under windows
If you forget MySQL's password under Windows, you can do this:
1. Close the running mysql service: net stop mysql or terminate the mysqld.exe process in windows Task Manager or find the mysql service in the management tool and stop it;
C:\Users\Administrator>net stop mysql MySQL Services are stopping. MySQL Service has been successfully discontinued
C:\Users\Administrator>cd C:\Program Files\MySQL\MySQL Server 5.5\bin C:\Program Files\MySQL\MySQL Server 5.5\bin>
Then return to the train, if there is no error message, it's OK.
Note: After skip-grant-tables parameter is used, login verification can be skipped.
C:\Program Files\MySQL\MySQL Server 5.5\bin>mysqld -nt --skip-grant-tables 140317 13:23:11 [Warning] option 'new': boolean value 't' wasn't recognized. Set to OFF.
5. Enter MySQL directly and return. If successful, there will be a MySQL prompt >
C:\Users\Administrator>cd C:\Program Files\MySQL\MySQL Server 5.5\bin C:\Program Files\MySQL\MySQL Server 5.5\bin>mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.5.35 MySQL Community Server (GPL) Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
mysql>USE mysql;
UPDATE user SET password=PASSWORD("123456") WHERE user="root";
mysql>FLUSH PRIVILEGES;
10. Log off or restart the computer, then open the MySQL service, and log in using the username root and the new password set.
2. Three Common Ways to Change mysql Password
In most cases, ordinary users do not have permission to change the password, only those who apply for permission or root can change the password.
1. Method 1: Use mysqladmin
mysqladmin -u root password "123456";
mysqladmin -u root password -p "123456";
mysql -u root -p mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456');
mysql> USE mysql; mysql> UPDATE user SET Password = PASSWORD('123456') WHERE user='root';