MySQL修改密码

MySQL修改密码

MYSQL5.7以下版本的数据库密码使用的是mysql这个数据库里的user表的password这个字段,
修改密码只需:

update mysql.user set password=password('root') where user='root';
flush privileges;

可是到了5.7版本,user表里就没有了password这个字段了,要想修改密码则需要用authentication_string这个字段:

updatemysql.user set authentication_string=password('root') where user='root';
flush privileges;

 MySQL忘记密码可以使用此方法更改:

修改MySQL的配置文件(默认为/etc/my.cnf),在[mysqld]下添加一行skip-grant-tables

原文地址:https://www.cnblogs.com/Mr-Ding/p/9579067.html