centos 7 下安裝mysql 遠程連接出現10038錯誤如何解決

版權聲明: https://blog.csdn.net/gq123456_/article/details/81031587

對於使用navicat premium工具鏈接MySQL的一些寫錯誤發,百度上面有很多都是讓你在my.ini/my.cnf/my.cnf.d下面刪除IP地址,我找了很久都沒有找到

出現上述情況

1、首先   設置遠程訪問權限 在mysql語句中執行語句

grant all privileges on *.* to 'root'@'%' identified by 'youpassword' with grant option;

flush privileges; //刷新MySQL的系統權限相關表

// % 允許訪問的IP地址,表示所有的IP都可以根據root用戶進行訪問

//youpassword 這邊填寫你的數據庫密碼

2、重啓MySQL

service mysql restart //重啓MySQL命令

至此這邊可以試一下能不能鏈接成功,如果還不行,往下看

3、centos7默認是firewall作爲防火牆,這裏改爲iptables

(1)、關閉firewall:

systemctl stop firewalld.service //停止firewall
systemctl disable firewalld.service //禁止firewall開機啓動

firewall-cmd --state    //查看默認防火牆狀態(關閉後顯示notrunning,開啓後顯示running)

(2)、配置iptables防火牆

service iptables status //先檢查是否安裝了iptables

yum install -y iptables //安裝iptables

yum update iptables  //升級iptables

yum install iptables-services //安裝iptables-services

(3)、編輯iptables防火牆文件

# sampleconfiguration for iptables service
# you can edit thismanually or use system-config-firewall
# please do not askus to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT[0:0]
:OUTPUT ACCEPT[0:0]
-A INPUT -m state--state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -jACCEPT
-A INPUT -i lo -jACCEPT
-A INPUT -p tcp -mstate --state NEW -m tcp --dport 22 -j ACCEPT //下面三行是自己加上去的,我也不是很懂什麼意思
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -jACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8080-j ACCEPT

-A INPUT -j REJECT--reject-with icmp-host-prohibite
-A FORWARD -jREJECT --reject-with icmp-host-prohibited
COMMIT

:wq! #保存退出

vi編輯器自行百度

(4)、重啓防火牆

systemctl restart iptables.service //最後重啓防火牆使配置生效

systemctl enable iptables.service //設置防火牆開機啓動

到這邊我是可以鏈接了








發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章