There are many ways to change the root password, let me summarize some common MySQL data to modify the root password method, there is a need to know or forget the root password of friends can enter the reference.
method One , with Mysqladmin
Here you use the two commands that come with MySQL Mysqladmin.exe and mysql.exe,mysqladmin change the password command format as follows
- -P[oldpass] password newpass
Note Oldpass (old password) optional, if the root default password is empty, you do not need to enter, if you need to change the old password, please note that the old password and-p do not have a space, otherwise will be error, the other password and newpass (new password) separated by a space.
- u rootmysql > SET for ' Root '@'localhost'= PASSWORD ('newpass' );
method Two : In DOS mode (CMD mode) Navigate to the MySQL installation directory in the subdirectory bin, call Mysql.exe to enter, i.e.
5. 1bin>--******
Use the Mysqladmin.exe command to modify the root password of MySQL
General MySQL root default password is empty, if you have not set the root password before using the Mysqladmin command, you can use the following mysqladmin command to modify the root password
5. 1bin>--1234565. 1bin>- -p123456
As described above using mysqladmin to first modify the root's default password, enter password enter, and then use the Mysql.exe command to enter root and its password to enter the MySQL command line.
If Root has already set a password, use the following method
mysqladmin -u root password oldpass "newpass"
Method 3: Edit the user table directly with update
- u rootmysql > Use Mysql;mysql > UPDATE User SET = PASSWORD ('newpass'WHEREuser=' Root ' ; MySQL > privileges;
This can be done when the root password is lost
-- skip-grant-tables& - u root mysqlmysql > UPDATE User SET Password=WHEREuser='root' ; MySQL > privileges;
Using phpMyAdmin to change the root password of MySQL is very convenient, installation configuration phpMyAdmin after the first login management interface, click on the right to change the password link, enter the MySQL root new password you want to modify, finally click to execute
Original address: http://www.manongjc.com/article/113.html
How MySQL modifies the password