MySQL8.0的root密码修改问题

/etc/my.cnf 在[mysqld]段中加上一句:

skip-grant-tables

使得数据库可以免密登录

本人实践过以下方式修改密码,但很遗憾,sql执行不成功

update mysql.user set authentication_string=password('123456a') where user='root';

我推荐使用以下方式

update mysql.user set authentication_string=‘’ where user='root'; //置空密码使root可以免密登录

恢复/etc/my.cnf配置重启MySQL

grant all on *.* to  'root' @ '%'  identified by  '新密码'  with grant option;//然后使用此语句修改
posted on 2020-12-10 16:50  Y冰鑫  阅读(78)  评论(0)    收藏  举报