centos7开启3306端口,liunx查看防火墙是否开启
Can't connect to MySQL server on localhost (10061)这个就属于下面要说的情况
启动服务
systemctl start mariadb.service
systemctl enable mariadb.service
systemctl stop mariadb.service
1.首先开启mysql权限
设置ROOT密码
mysqladmin -u root password '888888'
mysql -u root -p
use mysql
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mysql' WITH GRANT OPTION;
flush privileges;
第一句中"%"表示任何主机都可以远程登录到该服务器上访问。如果要限制只有某台机器可以访问,将其换成相应的IP即可,如:
GRANT ALL PRIVILEGES ON *.* TO root@"172.168.193.25" IDENTIFIED BY "root";
select * from user where user='root';
查看是否有%这条记录
2.开启3306端口及常用的其它端口
查看是否有这个文件/etc/sysconfig/iptables,如果没有
iptables -P OUTPUT ACCEPT
service iptables save 进行保存,默认就保存到了/etc/sysconfig目录下的iptables文件中
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT #允许3306数据库端口通过防火墙
service iptables save
cat /etc/sysconfig/iptables有3306这条信息
service iptables restart就ok咯
其它常用端口:
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT #允许80web端口通过防火墙
iptables -A INPUT -p tcp --dport 3306 -j ACCEPT
iptables -A INPUT -p tcp --dport 110 -j ACCEPT #email
iptables -A INPUT -p tcp --dport 25-j ACCEPT #email
iptables -A INPUT -p tcp --dport 20-j ACCEPT #ftp
iptables -A INPUT -p tcp --dport 21-j ACCEPT #ftp
iptables -A INPUT -p icmp -j ACCEPT #ping
iptables -A INPUT -p udp --dport 53 -j ACCEPT #DNS
3.查看防火墙是否开启:
service iptables status
active表示开启,inactive表示关闭
firewall-cmd --state
norunning
4.关于防火墙的命令
重启后永久性生效:
开启:chkconfig iptables on
关闭:chkconfig iptables off
即时生效,重启后失效:
开启:service iptables start
关闭:
service iptables stop
重启:service iptables restart
保存配置:service iptables save
或者/etc/rc.d/init.d/iptables save
#设置防火墙开机启动
systemctl enable iptables.service
禁止防火墙在系统启动时启动
/sbin/chkconfig --level 2345 iptables off
5.删除iptables规则
查看当前规则
iptables -L -n
iptables -L -n --line-number
iptables -D INPUT 3
centos7开启3306端口,liunx查看防火墙是否开启的更多相关文章
- Centos7防火墙开启3306端口
CentOS7的默认防火墙为firewall,且默认是不打开的. systemctl start firewalld # 启动friewall systemctl status firewalld # ...
- iptables 开启3306端口
[root@mysqld ~]# mysql -uroot -h 192.168.1.35 -p Enter password: ERROR 1130 (HY000): Host '192.168.1 ...
- Linux下防火墙开启相关端口及查看已开启端口
最近利用Apache Mina实现了一个http服务,发布到linux下发现无法访问,通过HttpClient来发送http请求时,报如下错误: Exception in thread "m ...
- centos7 开放3306端口并可以远程访问
开启远程访问: GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION; 允许任何ip以roo ...
- windows开启3306端口并用可视化工具访问远程mysql(授权访问)
开启 MySQL 的远程登陆帐号有两大步: 1.确定服务器上的防火墙没有阻止 3306 端口. MySQL 默认的端口是 3306 ,需要确定防火墙没有阻止 3306 端口,否则远程是无法通过 330 ...
- Linux开启相关端口及查看已开启端口
防火墙层面: /sbin/iptables -I INPUT -p tcp --dport 8011 -j ACCEPT #开启8011端口 /etc/rc.d/init.d/iptables ...
- Linux 开启相关端口及查看已开启端口
防火墙层面: /sbin/iptables -I INPUT -p tcp --dport 8011 -j ACCEPT #开启8011端口 /etc/rc.d/init.d/iptables ...
- mysql ubuntu 开启3306端口,设置远程访问
远程登陆数据库的时候出现了下面出错信息 :ERROR 2003 ( HY000 ) : Can 't connect to MySQL server on ' xxx.xxx.xxx.xxx ',经过 ...
- linux如何查看防火墙是否开启?删除iptables规则
iptables是linux下的防火墙组件服务,相对于windows防火墙而言拥有更加强大的功能,此经验咗嚛以centos系统为例.关于iptables的一般常见操作,怎么来判断linux系统是否启用 ...
随机推荐
- js抽奖
http://www.aichengxu.com/view/64369 <!Doctype html><html><head><meta http-equiv ...
- 基本套接字编程(1) -- tcp篇
1. Socket简介 Socket是进程通讯的一种方式,即调用这个网络库的一些API函数实现分布在不同主机的相关进程之间的数据交换. 几个定义: (1)IP地址:即依照TCP/IP协议分配给本地主机 ...
- ZooKeeper在centos6.4的集群搭建
首先给一个小tips,在搭建zookeeper之前,需要配置好java环境,请参看我的另一篇文章<Jdk1.8在CentOS7中的安装与配置>,还需要免密码登录,请参看我的另一篇文章< ...
- C常用数据类型长度
1.整型数据类型 2.无符号整型数据类型 3.字符型数据类型 char 字节数 1: 4.浮点型数据类型
- Web程序的桌面提醒
做web开发常会面对的一个问题是,浏览器最小化的时候如何才能向用户发送通知.解决办法大概有三种:让用户有事没事儿搂两眼页面:开发一个桌面客户端:Html5的Notification API. 目前没看 ...
- 使用Let's Encrypt手动创建https证书
Let's Encrypt是一个开源免费的SSL证书项目,是由 Mozilla.思科.Akamai.IdenTrust 和 EFF 等组织发起的,现由Linux基金会托管. 这篇博文分享的是使用let ...
- CoreCLR on Mac:体验managed exception handling
C#测试代码: using System; class Program { static void A() { try { Console.WriteLine("Throwing an ex ...
- ASP.NET中的KRE是什么?
KRE的英文全称是K Runtime Environment,其中K是ASP.NET vNext(后来叫ASP.NET 5)的项目代号. KRE是ASP.NET 5运行时环境,它是ASP.NET 5的 ...
- 第十四章:样式(Style)和主题(Theme)
简介 Android的样式(Style)和主题(Theme)文件就好比WEB开发中的CSS一样,可以实现UI界面的风格统一管理,这和Windows平台的XAML格式(Silverlight.WPF)类 ...
- 冲刺阶段 day 6
项目进展:学生管理这部分已经进展的差不多了,调试了几遍,改了几个小Bug之后就没有什么问题了,基本完成,如若后续还有一些新的功能到时候再自行加入.明天开始教师部分. 存在问题:我觉得我们的项目还是比较 ...