设置mysql通过IP地址远程连接
设置mysql通过IP地址远程连接,例如ECS自建mysql数据库。
一、修改配置文件,注释掉#bind-address = 127.0.0.1,注意路径选择
vi /etc/mysql/mysql.conf.d/mysqld.cnf
#bind-address = 127.0.0.1
二、使用root
账号登录mysql,执行授权命令
grant all on *.* to root@'%' identified by 'root密码' with grant option;
flush privileges;
三、重启数据库服务
/etc/init.d/mysql restart
四、注意安全保护,设置复杂密码等
五、查看授权
show grants;#localhost
show grants for root;#%
show grants for root@'%';#%
show grants for root@'192.168.8.88';#ip地址
六、解除授权
revoke all privileges on *.* from root@'%';
flush privileges;
未经同意,本站内容谢绝转载!