这样才能使本地Mysql服务允许被外部主机连接(两步)
网上的N多方法都不全面,只有下面的第一步或第二步是不行的,必须同时执行下面两步操作:
- 修改mysql.user表
以root
或debian-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;
- 修改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