mysql重置root密码

如果忘记了Mysql的root密码,那就只能重置了。
首先关闭mysql服务
rhel7

#systemctl stop mysqld

rhel6

#service mysqld stop

然后安全模式启动

#mysqld_safe –skip-grant-tables &
#mysql
>use mysql
>update user set password=password(“newpasswd”) where user=’root’;
>update user set authentication_string=password(“newpasswd”) where user=’root’; #mysql 7.8
>flush privileges;
mysql重置root密码_第1张图片
之后操作时还报错:You must SET PASSWORD before executing this statement解决
mysql> SET PASSWORD = PASSWORD(‘newpasswd’);
在重新设置一次密码

你可能感兴趣的:(mysql,重置密码)