centos7 mysql密码忘记的情况下更改mysql密码
忘记root密码情况下:
首先修改配置文件:vi /etc/my.cnf 添加 skip-grant-tables 保存退出即可:
重启mysql:systemctl restart mysqld
免密登录:mysql -u root
进入数据库:use mysql
修改root密码,命令如下:
update user set authentication_string = password(‘这里输入新密码’),password_last_changed=now() where user=‘root’;