开启 mysql 远程设置
1,登录 MySQL
2,创建用户用来远程连接
3,查看连接
mysql>use mysql;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
mysql> flush privileges;
#root 表示用户名;% 表示所有的电脑都可以连接,也可以设置某个 ip 地址运行;123456 为 root 密码
或 SELECT DISTINCT CONCAT('User:''',user,'''@''',host,''';') AS query FROM mysql.user;
mysql > select host,
user from user; + -----------+------+
| host | user |
+-----------+------+
|% | root | #主要要有这个
| 127.0.0.1 | root |
| linux | |
| linux | root |
| localhost | |
+-----------+------+
5 rows inset(0.00 sec)
4,然后打开 nano /etc/mysql/my.cnf
将 bind-address = 127.0.0.1 设置成 bind-address = 0.0.0.0 #(设备地址)
5,重新启动 mysql service mysql restart
6,如果有防火墙, service iptables stop // 临时关掉,也可以通过配置文件修改开放 3306
来源: http://www.bubuko.com/infodetail-2455228.html