Mysql 8.0 跳过并重置密码

1 关闭  mysql服务

systemctl stop mysql

 

2 查看mysql 服务状态 是否为关闭

systemctl status mysql

 

3. 编辑 etc/my.cnf

vim  /etc/my.cnf

[mysqld] 模块下添加 一行 skip-grant-tables  #跳过数据库权限验证

 

4开启mysql服务,登录mysql,不填写密码直接回车进入

systemctl start mysql
mysql -u root -p

 

5、设置密码为空

查看密码插件是否为 mysql_native_password

select user,host,plugin  from mysql.user;

 如果不是,则修改为mysql_native_password

use mysql;

 

6、退出mysql,并注释或者删除在/etc/my.cnf添加的 skip-grant-tables
vi /etc/my.cnf

 

7重启mysqld服务,设置新密码,并刷新权限。

 

8退出后即可使用新密码登录

 

posted @ 2024-05-10 10:24  飞行日志  阅读(25)  评论(0编辑  收藏  举报