一 进入Mysql bin目录
cmd 运行(跳过密码),运行完不要关闭
mysqld --console --skip-grant-tables --shared-memory
二 新打开一个cmd
mysql bin 目录下登录,密码输入时,直接回车
mysql -uroot -p
三 修改密码
mysql> use mysql;
mysql> update user set authentication_string = '' where user="root";
mysql> flush privileges;
mysql> quit
四 修改root权限(不必须)
root用户的连接权限仅为localhost,所以只能本地连接。
update user set host='%' where user='root';
五 重启并登录
1 关闭第一个cmd窗口,然后运行mysql 服务。文章来源:https://www.toymoban.com/news/detail-837249.html
2 密码输入时,直接回车文章来源地址https://www.toymoban.com/news/detail-837249.html
mysql -uroot -p
六 修改密码
# 'root'@'localhost' 根据你的权限,我在之前修改为'root'@'%'了
mysql> use mysql;
mysql> alter user 'root'@'localhost' identified by '你的密码';
mysql> flush privileges;
mysql> quit
到了这里,关于mysql 8 修改账号密码的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!