CentOS system MySQL forgot root user's password:
First step: (Stop running MySQL)
[Email protected] ~]#/etc/init.d/mysqldstop
Stoppingmysql: [OK]
Step two: restart MySQL with the "--skip-grant-tables" parameter [[Email protected] ~]# CD to the MySQL directory, here to the bin directory, will prompt "Please do a CD to the MySQL installation directory and restart"
[Email protected] ~]#./bin/mysqld_safe--skip-grant-tables
[email protected] ~]# starting mysqld daemon withdatabases from/var/lib/mysql
Note: If you stop at this point, clone a new session and proceed to the next step
Step Three: Log in to MySQL with your account
[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.
Fourth step: Change the user database
mysql> use MySQL
Reading table information for completion of table and ColumnNames
Can turn off this feature to get a quicker startup With-aDatabase changed
Fifth step: Change the password, the following () within the root123 is Xinmi code
Mysql>update user Set Password=password (' root123 ') whereuser= ' root ';
Query OK, 3 rows affected (0.00SEC)Rows matched:3 changed:3 warnings:0
Sixth step: Refresh the Permissions table
mysql> flush Privileges;
Error 1064 (42000): You have a error in your SQL syntax; Check themanual, corresponds to your MySQL server version for the Rightsyntax-use near ' previleges ' at line 1
Seventh step: Exit MySQL
Mysql> quit
Bye
Eighth Step: Restart MySQL
[Email protected] ~]#/etc/init.d/mysqldrestart;
Stoppingmysql: [OK]
Startingmysql: [OK]
Nineth Step: Re-login with a changed password.
[Email protected] ~]# mysql-u root-p
Enter password:admin123
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
[Email protected] ~]#
Add the following auto-start command/etc/rc.d/init.d/mysqld start
Reprint: http://blog.sina.com.cn/s/blog_4488002e0100z574.html
Reference: http://blog.chinaunix.net/uid-25266990-id-2921603.html
CentOS system MySQL forgot root user's password