1.先停止mysql
两种停用mysql
1. service mysql stop
2. /etc/init.d/mysql stop
2.进入维护模式
mysqld_safe --skip-grant-tables --skip-networking &
# --skip-grant-tables 跳过授权
# --skip-networking 跳过远程登陆
3.进入mysql (不需要密码)
4.刷新权限表
FLUSH PRIVILEGES;
5.修改密码
grant all on *.* to root@'localhost' identified by '123456'