mysql5.7设置允许外网访问登陆到mysql,管理mysql。 一、设置mysql服务允许外网访问
在/etc/my.cnf配置文件[mysqld]中增加port=3306 bind-address=0.0.0.0
vim /etc/my.cnfport=3306 bind-address=0.0.0.0
mysql.cnf bind_address.png
二、给mysql用户授权外网访问权限 1.登陆
mysql -uroot -p123456use mysql 2.查看用户
select user,host from user; 3.设置host为%
%为任意用户都有权限连接,localhost为只能本机连接,配置完host为%这一步就已经能外网访问了
update user set host='%' where user = 'root';
mysql host=%.png
4.授权用户具体权限
授权任意主机(@'%')通过root用户('root'@)用123456密码(identified by '123456')连接到mysql服务器
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;flush privileges;三、重启mysql生效
systemctl restart mysqld