1.使用安全模式进入MySQL
在/etc/mysql/mysql.conf.d/mysqld.cnf文件下的[mysqld]段下加入一行“skip-grant-tables”
2.重启mysql服务
sudo systemctl restart mysql
3. 使用安全模式进入MySQL并修改root密码
mysql
use mysql
update user set authentication_string=password('123456') where user='root' and Host ='localhost'; #把密码重置为123456
update user set plugin="mysql_native_password";
flush privileges;
quite
网友评论