1. 停止mysql服务

[root@db02data]#/etc/init.d/mysqldstopShuttingdownMySQL..SUCCESS!

2. 使用--skip-grant-tables启动mysql,忽略授权登录验证

[root@db02data]#mysqld_safe--skip-grant-tables--user=mysql>/dev/null2>&1&[1]30246

3. 登录mysql,修root密码

[root@db02data]#mysqlmysql>UPDATEmysql.userSETpassword=PASSWORD("123")WHEREuser='root'andhost='localhost';QueryOK,0rowsaffected(0.00sec)Rowsmatched:1Changed:0Warnings:0mysql>flushprivileges;QueryOK,0rowsaffected(0.01sec)mysql>quitBye

4. 退出mysql,并且重新启动mysql

[root@db02data]#/etc/init.d/mysqldstopShuttingdownMySQL..SUCCESS![1]+Donemysqld_safe--skip-grant-tables--user=mysql>/dev/null2>&1[root@db02data]#/etc/init.d/mysqldstartStartingMySQL.SUCCESS!