MySQL忘记Root用户密码
修改配置文件,将MySQL临时设置为免密登录
sudo vim /etc/mysql/my.cnf # 不同版本的配置文件路径可能不同。
# 在 [mysqld] 节点下添加以下配置:
[mysqld]
skip-grant-tables=1
重启MySQL服务
sudo systemctl restart mysql
修改root用户验证方式及密码
sudo mysql
mysql> use mysql;
mysql> update user set plugin='mysql_native_password' where user = 'root' and host = 'localhost';
mysql> update user set authentication_string=password('123') where user = 'root' and host = 'localhost';
mysql> flush privileges;
mysql> exit;

浙公网安备 33010602011771号