开启mysql远程设置
1、登录MySQL
2、创建用户用来远程连接
mysql> use mysql;
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION;
mysql> flush privileges;
#root表示用户名;%表示所有的电脑都可以连接,也可以设置某个ip地址运行;123456为root密码
3、查看连接
mysql>select host,user from user;
+-----------+------+
| host | user |
+-----------+------+
| % | root | #主要要有这个
| 127.0.0.1 | root |
| linux | |
| linux | root |
| localhost | |
+-----------+------+
5 rows in set (0.00 sec)
或 SELECT DISTINCT CONCAT(‘User: ‘‘‘,user,‘‘‘@‘‘‘,host,‘‘‘;‘) AS query FROM mysql.user;
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
原文地址:https://www.cnblogs.com/tengfeihhh/p/8252729.html