Set iptables in Linux to allow remote access to the MySQL Port

Source: Internet
Author: User
Modify the firewall configuration file: vi/etc/sysconfig/iptables add the following line:-ARH-Firewall-1-INPUT-mstate? StateNEW-mtcp-ptcp? If you want to open port 21 and other dport3306-jACCEPT, you only need to switch 3306 to port 21 to open. After the configuration, restart iptableser to modify the firewall configuration file:
Vi/etc/sysconfig/ IptablesAdd the following line:-A RH-Firewall-1-INPUT-m state? State NEW-m tcp-p tcp? Dport 3306-j ACCEPT
If you want to activate ports such as 21, you only need to replace 3306 with the ports to be opened, such as 21.
After configuration, restart iptable
Service iptables restart
Then you can access Mysql from other machines.
Note:
-A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport3306-j ACCEPT
-A RH-Firewall-1-INPUT-j REJECT -- reject-with icmp-host-prohibited-A RH-Firewall-1-INPUT-j REJECT -- reject-with icmp-host-prohibited
Is to reject icmp access. for other messages, the returned host is forbidden to access the error. The line that opens port 3306 must be before icmp-host-prohibited.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.