码迷,mamicode.com
首页 > 数据库 > 详细

linux 开启mysql远程连接

时间:2018-01-09 18:35:28      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:log   host   row   ice   设置   tab   打开   配置文件   mys   

 开启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

linux 开启mysql远程连接

标签:log   host   row   ice   设置   tab   打开   配置文件   mys   

原文地址:https://www.cnblogs.com/tengfeihhh/p/8252729.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!