1.修改mysqld.cnf配置文件
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
在[mysqld]中加入
skip-grant-tables

2.重启mysql
systemctl restart mysql
3.修改密码
mysql -u root
use mysql;
update user set authentication_string=password('新密码'),plugin='mysql_native_password' where user='root';
flush privileges;
exit
4.注释掉mysqld.cnf配置文件添加的skip-grant-tables
5.重启mysql

本文详细介绍了如何在不使用原始密码的情况下重置MySQL root用户的密码。步骤包括:修改mysqld.cnf配置文件以跳过权限表,重启MySQL服务,通过SQL命令更新root用户的密码,再次重启服务并注释掉配置更改。
7124

被折叠的 条评论
为什么被折叠?



