您的位置:首页 > 运维架构 > Linux

centos7下 mysql5.7 忘记密码重置

2017-08-11 15:13 363 查看
MySQL 5.7 开始 数据库中的user
表中已经将password 字段更改为authentication_string  所以更改密码 直接使用 update mysql.user
set authentication_string=password("123456") where user="root";


完整的修改数据库密码的操作

1. vim /etc/my.cnf 加入skip-grant-tables



2.重启mysql  systemctl restart mysqld

3.终端输入mysql  直接登录到数据库  use mysql ;

4.update mysql.user set authentication_string=password("123456") where user="root";

5.编辑my.cnf文件删掉skip-grant-tables 这一行,然后重启MySQL,/etc/init.d/mysqld restart,否则MySQL仍能免密码登录

6.mysql -uroot -p



接下来MySQL就可以正常运行了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: