ubuntu 16.04下mysql5.7.17开放远程3306端口
作者:_supernatural 时间:2024-01-17 13:00:03
开启MySQL的远程访问权限
默认mysql的用户是没有远程访问的权限的,因此当程序跟数据库不在同一台服务器上时,我们需要开启mysql的远程访问权限。
主流的有两种方法,改表法和授权法。
相对而言,改表法比较容易一点,个人也是比较倾向于使用这种方法,因此,这里只贴出改表法
1、登陆mysql
mysql -u root -p
2、修改mysql库的user表,将host项,从localhost改为%。%这里表示的是允许任意host访问,如果只允许某一个ip访问,则可改为相应的ip,比如可以将localhost改为192.168.1.123,这表示只允许局域网的192.168.1.123这个ip远程访问mysql。
mysql> use mysql;
mysql> select host,user form user;
mysql>update user set host = '%' where user ='root';
mysql>select host,user from user;
mysql> flush privileges;
mysql> quit;
首先查看端口是否打开 netstat -an|grep 3306
打开mysql配置文件vim /etc/mysql/mysql.conf.d/mysqld.cnf
将bind-address = 127.0.0.1注销
重启动ubuntu
再次查看端口是否打开 netstat -an|grep 3306
================================
将root用户授权给所以连接:grant all privileges on *.* to 'root'@'%' identified by 'xxxxxx';
最后一个为mysql密码
让权限立即生效:flush privileges;
到此所以操作完成,可以在任何主机连接此mysql数据库服务器了。
MySQL远程连接不上的解决:https://www.jb51.net/article/103770.htm
Centos7.1防火墙开放端口:https://www.jb51.net/article/103777.htm
CentOS 7开放端口:https://www.jb51.net/article/103773.htm
ubuntu 15.04 mysql开放远程3306端口:https://www.jb51.net/article/103784.htm
https://www.jb51.net/article/103766.htm
root@3bc476b7e0d5:~# vim /etc/mysql/mysql.conf.d/mysqld.cnf
root@3bc476b7e0d5:~# netstat -an | grep 3306
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
root@3bc476b7e0d5:/# service mysql enable
Usage: /etc/init.d/mysql start|stop|restart|reload|force-reload|status
root@3bc476b7e0d5:/# netstat -an | grep 3306
tcp6 0 0 :::3306 :::* LISTEN
root@3bc476b7e0d5:/# mysql --version
mysql Ver 14.14 Distrib 5.7.16, for Linux (x86_64) using EditLine wrapper
root@3bc476b7e0d5:/# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.16-0ubuntu0.16.04.1 (Ubuntu)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| fabric |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.02 sec)
来源:http://blog.csdn.net/williamfan21c/article/details/54619220
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
asp和js两种方法判断远程图片是否存在
python是先运行metaclass还是先有类属性解析
Django REST framework视图的用法
![](https://img.aspxhome.com/file/2023/9/127649_0s.png)
Python获取时间范围内日期列表和周列表的函数
![](https://img.aspxhome.com/file/2023/8/75928_0s.png)
python爬取网页转换为PDF文件
![](https://img.aspxhome.com/file/2023/3/134953_0s.jpg)
asp之自动闭合HTML/ubb标签函数附简单注释
python3实现名片管理系统
微信跳一跳python代码实现
Python数据相关系数矩阵和热力图轻松实现教程
![](https://img.aspxhome.com/file/2023/4/89434_0s.jpg)
Python编程使用PyQt5库实现动态水波进度条示例
![](https://img.aspxhome.com/file/2023/5/78755_0s.gif)
Python简洁优雅的推导式示例详解
一篇文章搞懂Python反斜杠的相关问题
![](https://img.aspxhome.com/file/2023/2/97662_0s.png)
js+CSS实现弹出居中背景半透明div层的方法
python3利用Dlib19.7实现人脸68个特征点标定
![](https://img.aspxhome.com/file/2023/4/76034_0s.jpg)
python matplotlib自定义colorbar颜色条及内置色条详解
![](https://img.aspxhome.com/file/2023/6/79436_0s.png)
跟老齐学Python之关于类的初步认识
python list数据等间隔抽取并新建list存储的例子
jquery 常用操作
pytest-sugar 执行过程中显示进度条的脚本分享
Python著名游戏实战之方块连接 我的世界
![](https://img.aspxhome.com/file/2023/9/100799_0s.gif)