vi /etc/my.cnf
在mysqld块中添加一行
[mysqld]
skip-grant-tables
重启:
systemctl restart mysqld
登录:
mysql
修改密码:
use mysql
#将密码置空
update user set authentication_string ='' where user ='root';
退出
exit;
vi /etc/my.cnf
在mysqld块中注释掉这一行
[mysqld]
skip-grant-tables
重启:
systemctl restart mysqld
登录:
mysql
修改密码:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';
flush privileges;