- vim /etc/my.cnf 添加skip-grant-tables
- 重启 systemctl restart mysqld.service
- 进mysql -u root -p
- 将root 密码设置为空 authentication_string是MySQL8.0 的usr里的密码字段
use mysql; (使用mysql数据表)
update user set authentication_string='' where user='root';(将密码置为空)
exit (退出mysql)
- 注释skip-grant-tables
进mysql -u root -p 直接回车
- ALTER USER 'root'@'%' IDENTIFIED BY 'password';(password是你要更改后的密码)