Mysql 5.7 重置root密码
- 修改mysql配置文件 vim /etc/my.cnf
- 在my.conf中[mysqld]下新增一行添加
skip-grant-tables # 略过权限表
- 重启mysql : /etc/init.d/mysqld resatrt
mysql –uroot –p 不用输入密码直接进入命令行界面
3.1 use mysql
3.2 update user set authentication_string=PASSWORD('newpassword') where User='root';
3.3 flush privileges;
- 在修改表权限,重启mysqld
错误解决
提示1)You must reset your password using ALTER USER statement before executing this statement表明密码简单,需要重新更改密码,执行语句:
alter table user root@localhost identified by ‘password@2019!’;
或者ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘MyNewPass4!’;
2) Your password has expired. To log in you must change it using a client that supports expired passwords 表明密码设置的有过期时间,执行语句:
update user set password_expired=’N’ where user=’root’;
flush privileges;