1.停止mysql服务
service mysqld stop
2.跳过授权表
–skip-garnt-tables
–skip-networking
[root@db01 ~]# mysqld_safe --skip-grant-tables --skip-networking &
3.登录mysql开启授权表
mysql> flush privileges;
4.改密码
mysql> alter user root@'localhost' identified by '123456';
5.重启到正常模式
/etc/init.d/mysqld restart