Use the MySQL Change Password command to change the root password.
There are two ways to enter the MySQL database command line mode:
Mode one: In the MySQL Start menu contains the MySQL command line client, just click enter root password to enter.
Mode two: In DOS mode (CMD mode) Navigate to the MySQL installation directory in the subdirectory bin, call Mysql.exe to enter, i.e.
======================== the following is the command ===================================
C:\Program files\mysql\mysql Server 5.1\bin>mysql-u Root
Enter Password: ******
======================== above is the command ===================================
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
======================== the following is the command ===================================
C:\Program files\mysql\mysql Server 5.1\bin>mysqladmin-u root-p password 123456
Enter Password
C:\Program files\mysql\mysql Server 5.1\bin>mysql-u root-p123456
======================== above is the command ===================================
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 you have set the root password for MySQL and now need to modify it and go to MySQL command line mode, enter
======================== the following is the command ===================================
C:\Program files\mysql\mysql Server 5.1\bin>mysqladmin-u root-p123456 Password root
C:\Program files\mysql\mysql Server 5.1\bin>mysql-u root-proot
======================== above is the command ===================================
Can.
Here you use the two commands that come with MySQL Mysqladmin.exe and mysql.exe,mysqladmin change the password command format as follows
Mysqladmin-u Root-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.
MySQL command is similar to the mysqladmin command format, mainly used to enter the correct user name and password after entering the MySQL command line mode, the format is as follows
Mysql-u Root-p[password]
If you do not enter password, the Enter password prompt will appear after the carriage return. If the root password is empty, you do not need to enter password, the Enter password prompt and enter.
At this point, the common MySQL change root password method and command is finished, it should be said that the root password of MySQL is very important, if you forget the root password or stolen, will have serious consequences, it is recommended to rename the root user, Or create a new user in the User Permissions table, giving the usual minimum permissions configuration to ensure the security of the site, and to reset or change the root password in the future.