vim /etc/my.cnf
# 在 [mysqld] 模块下加入一行代码
skip-grant-tables
#直接输入mysql 登录
$ mysql
mysql > use mysql;
mysql > update user set authentication_string = password('123123') where user = 'root';
mysql > flush privileges;
mysql > quit;
# 进入 /etc/my.cnf 删掉skip-grant-tables
$ systemctl restart mysqld
网友评论