Method 1: use the SET PASSWORD command
Log in first MySQL,
Format: mysql> Set the password for user name @ localhost=password (' new password ');
Example: mysql> Set the password for root @ localhost=password (' 123 ');
Method 2: use mysqladmin
Format: mysqladmin -u username -p
old password password the new passwordExample: mysqladmin uroot - p123456 password 123
Method 3: use the UPDATE directly edit user table
Log in first MySQL,
Mysql> The use of mysql;
Mysql> Update the user set the password=password (' 123 ') where the user='root' and the host='localhost'
Mysql> flush privileges;
Method 4: forget the root password, it can be
In Windows, for example:
1. Shut down the running MySQL service,
2. Open a DOS window, turn to mysql \ bin directory,
3. Input mysqld - skip - grant - tables carriage return, - skip - grant - the meaning of the tables is the time to start the MySQL service skip permissions table certification,
4. To open a DOS window (because the DOS window has been can't move just now), turn to mysql \ bin directory,
5. Enter the mysql enter, if successful, will appear the mysql prompt & gt; ,
6. Connect the access database: use mysql; ,
6. Change password: update the user set the password=password (" 123 ") where the user="root"; (don't forget to add a semicolon),
7. Refresh the permissions (must) : flush privileges; ,
8. Quit quit,
9. Cancellation of system, and then, using the username root and just set the new password log in 123,