Switch to the MySQL installation directory under cmd
Example
D:/MySQL/bin(If Wamp is used for installation, it is D:/Wamp/bin/MySQL/mysql5.1.30/bin)
Prerequisites: the MySQL Root Password is empty.
InputMysql-u root MySQL
Mysql> enter update user SET Password = PASSWORD ('new password') where user = 'root ';
Echo
Query OK, 0 rows affected (0.00 Sec)
Rows matched: 2 changed: 0 Warnings: 0
Mysql> Status, enter flush privileges;
Echo
Query OK, 0 rows affected (0.00 Sec)
Mysql> enter quit
Exit SQL
Note that a semicolon ";" must be added after each command ";"
MySQL started to execute this command
The second command updates the database of the MySQL system that has been loaded into the memory.
Restart MySQL.
After updating the root password, you can use the following methods to connect to MySQL:
New mysql-u root-P Password
2. Change the MySQL Root blank in phpMyAdmin to the new password.
Example: In the config. inc file under D:/Wamp/apps/phpmyadmin3.0.1.1
$ Cfg ['servers'] [$ I] ['Password'] = ''changed
$ Cfg ['servers'] [$ I] ['Password'] = 'newpassword'