標籤:emc 本地 cep firewalld ESS 成功 pre mariadb save
首先:centos 7 使用的防火牆為:firewall 不是iptables
查看已經開放的連接埠:此處我已經開啟了mysql的連接埠
[[email protected] ~]# firewall-cmd --list-ports
3306/tcp
開啟連接埠: 提示success表示開啟成功
[[email protected] ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
success
命令的含義:
--zone # 表示範圍
--add-port=3306/tcp #添加連接埠,格式為:連接埠號碼/通訊協議
--permanent #永久生效,沒有此參數重啟後失效
需要重啟防火牆:
firewall-cmd --reload #重啟firewall
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall開機啟動
查看監聽(Listen)的連接埠
netstat -lntp
檢查連接埠被哪個進程佔用
netstat -lnp|grep 8080
重啟防火牆後,需要在mysql中設定可以遠端存取的帳號
[[email protected] ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
MariaDB [(none)]> create user ‘username‘@‘%‘ identified by ‘password‘;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all on *.* ‘username‘@‘%‘;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘‘zhengwei‘@‘%‘‘ at line 1
MariaDB [(none)]> grant all on *.* to ‘zhengwei‘@‘%‘;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
然後再本地測試連接是否成功!
CentOS 7 以下版本 iptables 命令
如要開放80,22,8080 連接埠,輸入以下命令即可
1、/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT2、/sbin/iptables -I INPUT -p tcp --dport 22 -j ACCEPT3、/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
然後儲存:
/etc/rc.d/init.d/iptables save
查看開啟的連接埠:
/etc/init.d/iptables status
關閉防火牆
1) 永久性生效,重啟後不會複原
開啟: chkconfig iptables on
關閉: chkconfig iptables off
2) 即時生效,重啟後複原
開啟: service iptables start
關閉: service iptables stop
Navicat遠端存取vm中安裝mysql