One: ( stop running MySQL)
[[email protected] ~]# service mysql stop
Second: Restart MySQL with the "--skip-grant-tables" parameter
[email protected] ~]# mysqld_safe--skip-grant-tables &
[1] 23810
starting mysqld daemon with databases From/var/lib/mysql
Three: Use rootAccount Login MySQL
[email protected] ~]# mysql-u root
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 1
Server version:5.0.77 Source distributiontype ' help, ' or ' \h ' for help. Type ' \c ' to clear the buffer.
Four: Change user database
mysql> use MySQL
Reading table information for completion of table and column names
can turn off this feature to get a quicker startup With-adatabase changed
Five: Change Password, rememberPasswordto use password ()function for encryption
mysql> Update user set Password=password (' Netdak ') where user= ' root ';
Query OK, 1 row affected (0.04 sec)
Rows matched:1 changed:1 warnings:0
Six: Refresh the permissions table
mysql> flush Privileges;
Query OK, 0 rows Affected (0.00 sec)
Seven: Quit MySQL
Mysql> quit
Bye
eight: to MySQLto restart
[[Email protected] ~]# service MySQL restart;
stopping server from PID file/var/run/mysqld/mysqld.pid
100421 13:44:03 mysqld endedstopping MySQL: [OK]
starting MySQL: [OK]
[1]+ done Mysqld_safe--skip-grant-tables
Nine: Use a changed passwordyou can log in again.
[email protected] ~]# mysql-u root-p
Enter Password:netdak
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 2
Server version:5.0.77 Source distributiontype ' help, ' or ' \h ' for help. Type ' \c ' to clear the buffer.mysql> quit
Bye
10. Re-execute Password change
SET PASSWORD = PASSWORD (' 123456 ');
Note: The tenth step is not required, but MySql5.6 operation may be error: You must SET PASSWORD before executing this statement.