-
打开配置文件:vim /etc/my.cnf.d/mysql-server.cnf
-
将下面添加到文件内:
[mysqld]
skip-grant-tables
如果文件中已存在[mysqld]则直接将skip-grant-tables写到其下方即可。
- 修干完成后,保存退出,重启服务:systemctl restart mysqld
- 使用命令sudo mysql -uroot 重新连接mysql服务器,此时可以不实用密码直接登录用户。
-
执行update mysql.user set authentication_string=password(‘新密码’) where user=”用户名”;修改root用户的密码。
- 执行flush privileges;刷新策略,
- 修改vim /etc/my.cnf.d/mysql-server.cnf 文件,注释掉第二步添加的两段内容
- 运行,sudo systemctl restart mysqld 重启MySQL服务器
mysql8 忘记密码怎么办
最新推荐文章于 2024-06-12 10:54:23 发布