CentOS 7配置MariaDB允许指定IP远程连接数据库
防火墙
CentOS7 之前的防火墙是不一样的,比如你要添加3306端口:
## 全部
iptables -A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT ## 部分ipiptables
iptables -A INPUT -p tcp -s 138.111.21.11 -dport 3306 -j ACCEP service iptables save service iptables restart ## 查看 iptables
iptables -L -n
但这个在CentOS 7 就不好使,查看文档才知道CentOS 7 使用了增强版firewall
firewall-cmd --zone=public --permanent --add-port=3306/tcp
1、firwall-cmd:是Linux提供的操作firewall的一个工具;
2、--permanent:表示设置为持久;
3、--add-port:标识添加的端口;
4、--zone=public:指定的zone为public;
当然如果不太习惯使用命令,我们可以直接改配置文件

进入etc/firewalld/zone中,修改public.xml
<?xml version="1.0" encoding="utf-8"?>
<zone>
<short>Public</short>
<description>For use in public areas.</description>
<rule family="ipv4">
<source address="122.10.70.234"/>
<port protocol="udp" port="514"/>
<accept/>
</rule>
<rule family="ipv4">
<source address="123.60.255.14"/>
<port protocol="tcp" port="10050-10051"/>
<accept/>
</rule>
<rule family="ipv4">
<source address="192.249.87.114"/> 放通指定ip,指定端口、协议
<port protocol="tcp" port="80"/>
<accept/>
</rule>
<rule family="ipv4"> 放通任意ip访问服务器的9527端口
<port protocol="tcp" port="9527"/>
<accept/>
</rule>
</zone>
上述配置文件可以看出:
1、添加需要的规则,开放通源ip为122.10.70.234,端口514,协议tcp;
2、开放通源ip为123.60.255.14,端口10050-10051,协议tcp;/3、开放通源ip为任意,端口9527,协议
firewall 常用命令 # 重启
service firewalld restart # 开启
service firewalld start # 关闭
service firewalld stop # 查看firewall 服务状态
systemctl status firewall # 查看防火墙
firewall-cmd --list-all

开启服务器3306对外开放后,还需要设置数据库用户授权
MariaDB 开启远程连接
在数据库
mysql中的user表中可以看到默认是只能本地连接的,所有可以添加一个用户
# 针对ip
create user 'root'@'192.168.10.10' identified by 'password';
#全部
create user 'root'@'%' identified by 'password';
建议还是针对于ip开放吧,不要全部开放
授权用户:
# 给用户最大权限
grant all privileges on *.* to 'root'@'%' identified by 'password'; # 给部分权限(test 数据库) grant all privileges on test.* to 'root'@'%' identified by 'password' with grant option; # 刷新权限表 flush privileges; # show grants for 'root'@'localhost';

接下来就是可以本地连接了。
Ubuntu 16.04 LTS 上安装 Nginx、MariaDB 和 HHVM 运行 WordPress http://www.linuxidc.com/Linux/2016-10/136435.htm
Ubuntu 16.04 Dockerfile 安装MariaDB http://www.linuxidc.com/Linux/2016-09/135260.htm
Linux系统教程:如何检查MariaDB服务端版本 http://www.linuxidc.com/Linux/2015-08/122382.htm
Ubuntu 16.04下如何安装MariaDB http://www.linuxidc.com/Linux/2017-04/142915.htm
CentOS 7.3二进制安装MariaDB10.2.8步骤 http://www.linuxidc.com/Linux/2017-10/147904.htm
CentOS 7 编译安装MariaDB-10.1.22 http://www.linuxidc.com/Linux/2017-05/143291.htm
Ubuntu 上如何将 MySQL 5.5 数据库迁移到 MariaDB 10 http://www.linuxidc.com/Linux/2014-11/109471.htm
[翻译]Ubuntu 14.04 (Trusty) Server 安装 MariaDB http://www.linuxidc.com/Linux/2014-12/110048htm
Ubuntu 14.04(Trusty)安装MariaDB 10数据库 http://www.linuxidc.com/Linux/2016-11/136833.htm
MariaDB 的详细介绍:请点这里
MariaDB 的下载地址:请点这里
CentOS 7配置MariaDB允许指定IP远程连接数据库的更多相关文章
- CentOS6.5 配置防火墙+允许指定ip访问端口
参考博文: iptables防火墙只允许指定ip连接指定端口.访问指定网站 一.配置防火墙 打开配置文件 [root@localhost ~]# vi /etc/sysconfig/iptables ...
- centos安装配置mariadb
CentOS7下使用yum安装MariaDB CentOS 6 或早期的版本中提供的是 MySQL 的服务器/客户端安装包,但 CentOS 7 已使用了 MariaDB 替代了默认的 MySQL.M ...
- WIN2003使用IP安全策略只允许指定IP远程桌面连接
一,新建IP安全策略 WIN+R打开运行对话框,输入gpedit.msc进入组策略编辑器. 依次打开“本地计算机”策略--计算机配置--Windows设置--安全设置--IP安全策略,在 本地计算机上 ...
- 配置tomcat限制指定IP地址访问后端应用
1. 场景后端存在N个tomcat实例,前端通过nginx反向代理和负载均衡. tomcat1 tomcatN | | | ...
- CentOS 7 配置 mariadb
一.安装mariadb : yum groupinstall mariadb mariadb-client -y 二.启动(设置开机启动)服务 : systemctl start (enabl ...
- CentOS中配置xrdp,通过微软远程桌面访问CentOS桌面
环境:CentOS 6.4 1.安装相关软件 yum groupinstall "Desktop" (已安装桌面的就可以缺略这条命令) yum install xrdp yum i ...
- CentOS 6 网络设置修改 指定IP地址 DNS 网关
环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G) 系统版本:Centos-6.5-x86_64 路由器网关:192.168.1.1 步骤: 1.查看网络MAC地址 [ro ...
- Linux中CentOS网络配置以及与Xshell建立远程连接
为centos配置网络 (1)第一步 点开虚拟机的设置,如下图做相关的设置: 网络连接要选择桥接模式,其他的勾选就按照上图的即可,勾选完成点击确定. (2)第二步 点击VMware的编辑选项,找到“虚 ...
- CentOS下配置MySQL允许root用户远程登录
1.常用命令: 安装上传下载文件命令yum install lrzsz安装webget工具yum -y install wget ----------------------------------- ...
随机推荐
- gitlab简介与配置
版本控制介绍 版本控制是指对软件开发过程中各种程序代码.配置文件及说明文档等文件变更的管理,是软件配置管理的核心思想之一. 版本控制最主要的功能就是追踪文件的变更.它将什么时候.什么人更改了文件的什么 ...
- AndroidStudio 问题点 - app:preFUNDebugAndroidTestBuild
Error:Execution failed for task ':app:preFUNDebugAndroidTestBuild'. >Conflictwith dependency 'com ...
- dremio jdbc使用
驱动包地址 链接:https://pan.baidu.com/s/1Nivkvze24hRH8pXOQleCgw 提取码:gp9z 使用dremio主要原因 : 1)springboot提供了es组件 ...
- ASP.NET代码调用SQL Server带DateTime类型参数的存储过程抛出异常问题
ASP.NET代码调用SQL Server带DateTime类型参数的存储过程,如果DateTime类型参数的值是'0001/1/1 0:00:00'时,就会抛出异常“Message: SqlDate ...
- Codeforces Round #485 (Div. 2) D. Fair
Codeforces Round #485 (Div. 2) D. Fair 题目连接: http://codeforces.com/contest/987/problem/D Description ...
- eslint 的 env 配置是干嘛使的?
这笔修改体现了 env 和 global 的关系: https://github.com/g8up/youDaoDict/commit/8b05616f 官方文档表述: https://eslint. ...
- Git Gui for Windows的建库、克隆(clone)、上传(push)、下载(pull)、合并(转)
Git Gui for Windows的建库.克隆(clone).上传(push).下载(pull).合并(转) from:http://hi.baidu.com/mvp_xuan/blog/item ...
- Mimikatz 法国神器
0x00 标准模块 Module : standardFull name : Standard moduleDescription : Basic commands (does not require ...
- repo跟svn的区别
Git与SVN区别 Git和SVN正好相反,git提倡开发时拉分支,各干各的,相互独立,发版本时打标签:而svn呢,平时大家都在主干上干活,发版本时拉个分支,所以呢,svn经常会提交冲突,经常要合并代 ...
- hbuilder下用plus.barcode.Barcode做二维码扫描,当二维码容器的高度设置过低时,启动扫描会发生闪退
解决办法: 将固定高度改为百分比