婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > Mysql服務添加 iptables防火墻策略的方案

Mysql服務添加 iptables防火墻策略的方案

熱門標簽:html地圖標注并導航 400電話辦理服務價格最實惠 催天下外呼系統 武漢電銷機器人電話 400電話變更申請 呂梁外呼系統 北京金倫外呼系統 南太平洋地圖標注 大豐地圖標注app

如果你的Mysql數據庫安裝在centos7的系統上,并且你的操作系統啟用了防火墻。應用要訪問mysql數據庫,你有2個解決方案。

方案一:停止防火墻服務
方案二:在防火墻中添加策略,讓應用能正常訪問mysql服務端口

停止Centos7防火墻

查看防火墻運行狀態

[root@mysql ~]# firewall-cmd --state
running

停止防火墻服務

[root@mysql ~]# systemctl stop firewalld.service

啟動Centos7防火墻

查看防火墻運行狀態

[root@mysql ~]# firewall-cmd --state
not running

啟動防火墻服務

[root@mysql ~]# systemctl start firewalld.service

配置防火墻開機啟動

[root@mysql ~]# systemctl enable firewalld.service

訪問Mysql服務測試
連接Mysql服務

[mysql@mysql ~]$ mysql -utony -ptony -h 192.168.112.131 -P 3306
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.112.131' (113)

主從復制連接測試[root@localhost] 15:23:46 [(none)]>show slave status\G;
*************************** 1. row ***************************
               Slave_IO_State: Connecting to master
                  Master_Host: 192.168.112.131
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: binlog.000034
          Read_Master_Log_Pos: 194
               Relay_Log_File: mysql-relay-bin.000007
                Relay_Log_Pos: 401
        Relay_Master_Log_File: binlog.000034
             Slave_IO_Running: Connecting
            Slave_SQL_Running: Yes
           .....
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 2003
                Last_IO_Error: error connecting to master 'repl@192.168.112.131:3306' - retry-time: 60  retries: 1
               Last_SQL_Errno: 0

主從的IO線程已斷開,并且報2003錯誤,這里就確認是網絡不通,訪問不了主庫的服務。

在防火墻中添加Mysql服務訪問策略

查看防火墻策略

[root@mysql ~]# iptables -L -n --line-number|grep 3306

由于在防火墻中沒有添加3306端口的訪問策略,外部應用是無法mysql服務的。

[mysql@mysql ~]$ mysql -utony -ptony -h 192.168.112.131 -P 3306
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.112.131' (113)

添加3306端口訪問策略

# iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
[root@mysql ~]# iptables -L -n --line-number|grep 3306
1    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:3306

可以看到已經添加了3306端口的訪問策略,外部應用可以通過TCP協議訪問3306端口。

刪除防火墻策略

[root@mysql ~]# iptables -D INPUT 1
[root@mysql ~]# iptables -L -n --line-number|grep 3306

到此這篇關于給Mysql服務添加 iptables防火墻策略的文章就介紹到這了,更多相關Mysql服務添加 iptables防火墻內容請搜索腳本之家以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持腳本之家!

您可能感興趣的文章:
  • linux下mysql開啟遠程訪問權限 防火墻開放3306端口
  • linux下mysql鏈接被防火墻阻止的解決方法

標簽:西寧 無錫 龍巖 南充 麗水 自貢 迪慶 徐州

巨人網絡通訊聲明:本文標題《Mysql服務添加 iptables防火墻策略的方案》,本文關鍵詞  Mysql,服務,添加,iptables,防火墻,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《Mysql服務添加 iptables防火墻策略的方案》相關的同類信息!
  • 本頁收集關于Mysql服務添加 iptables防火墻策略的方案的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 自贡市| 顺义区| 清徐县| 舟曲县| 黔西县| 新竹县| 兴文县| 湘阴县| 汤阴县| 田林县| 乌兰浩特市| 同心县| 宁河县| 福建省| 敦煌市| 沁水县| 古蔺县| 会理县| 灵台县| 察雅县| 安吉县| 锦州市| 甘肃省| 裕民县| 莱阳市| 衡南县| 永福县| 乡宁县| 福建省| 丹阳市| 安庆市| 岗巴县| 龙陵县| 桦甸市| 卓尼县| 宾阳县| 榆林市| 平武县| 西乌珠穆沁旗| 萨迦县| 浑源县|