1、设置msyql跳过密码
修改 /etc/my.cnf,在 [mysqld] 组下添加一行:skip-grant-tables=1
2、重启mysql
重启 mysql 服务
3、修改密码
update mysql.user set authentication_string=password(‘root’) where user=‘root’ and Host = ‘localhost’;
flush privileges;
在之前的版本中,密码字段的字段名是 password,5.7版本改为了 authentication_string
4、改回my.cnf,重启mysql
去掉skip-grant-tables=1 重启mysql
参考:https://blog.csdn.net/dugufeilei/article/details/102568439
5、登录修改允许所有机器登录root
GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘123456’ WITH GRANT OPTION;
flush privileges;
参考:https://blog.csdn.net/dugufeilei/article/details/106383195