进入 /etc/my.cnf 文件,找到 [mysqld] ,在其后面添加 skip-grant-tables
vi /etc/my.cnf

image.png
重启mysql
systemctl restart mysqld

image.png
重新登录数据库,搞定
mysql -u root -p

image.png
进入 /etc/my.cnf 文件,找到 [mysqld] ,在其后面添加 skip-grant-tables
vi /etc/my.cnf
重启mysql
systemctl restart mysqld