MySQL8重置密码 —— Centos8
MySQL8重置密码 —— Centos8
查看my.cnf所处位置
ls /etc/my.cnf

如果此位置找不到,可以全盘搜索一下 my.cnf
修改my.cnf
sudo vim /etc/my.cnf


进来后在 [mysqld] 下添加
skip-grant-tables

重启mysql服务
sudo systemctl restart mysqld

无密码登录mysql
mysql -uroot

选择数据库并修改root密码
use mysql;
update user set authentication_string='密码' where user='root';

回到my.cnf删除刚才添加的那行
略

重启服务
sudo systemctl restart mysqld


浙公网安备 33010602011771号