首先说一下,mysql5.7跟mysql5.6及之前的版本有些不同,它的password字段,字段名修改为authentication_string。因此具体的修改步骤会有一些不同。
(1)设置其为免密登录

1)
vim /etc/my.cnf  
##在my.cnf的[mysqld]字段加入
skip-grant-tables
(2##重启mysql服务
service mysqld restart

(2)免密登录mysql

mysql
##直接回车登录

(3)将root重置密码为空

use mysql;
update user set authentication_string='' where user='root';
flush privileges;

(4)首先要退出mysql,删除/etc/my.cnf文件最后的 skip-grant-tables 重启mysql服务,使用root用户进行登录,因为上面设置了authentication_string为空,所以可以免密码登录。

(5)修改密码并设置成为所有外部ip都可使用该密码进行连接

use mysql;
Grant all on *.* to 'root'@'%' identified by 'root用户的密码' with grant option;
flush privileges;
Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐