这样才能使本地Mysql服务允许被外部主机连接(两步)

网上的N多方法都不全面,只有下面的第一步或第二步是不行的,必须同时执行下面两步操作

  1. 修改mysql.user表
    rootdebian-sys-maint身份登录mysql
$ mysql -u debian-sys-maint -p
mysql> use mysql
mysql> select Host, User from user;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'lxw'@'%' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
  1. 修改mysql配置文件
$ pwd
/etc/mysql/mysql.conf.d
$ vim mysqld.cnf  #对应修改下面的内容
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address           = 127.0.0.1
bind-address            = 0.0.0.0

修改完成后,需要重新启动mysql服务

$ /etc/init.d/mysql restart

References:

外部主机不允许连接Mysql设置的解决
mysql下怎样创建新用户,并允许其在任意主机登录啊

posted @ 2017-02-28 22:47  XiaoweiLiu  阅读(1603)  评论(0编辑  收藏  举报