In linux, external access to the mysql database is unavailable.

Source: Internet
Author: User

In linux, the mysql database cannot be accessed externally. However, the mysql database is installed in the CentOS System of the virtual machine, but cannot be accessed externally after the installation is successful. It took a long time to find out the problem because of the firewall settings. Now I will write the solution process and share it with you. First, check the mysql permissions. The service has been started and can be successfully logged on to localhost. The iptables firewall also enables port 5506 (I prefer port 5506 when installing mysql, rather than the default port 3306 ). Www.2cto.com then, when I connect to the database in my VM in the local environment, why cannot I link it? The Error Code 2003 is displayed. This is because the network connection fails. SQLyog can connect to the database through ssh, which means that the network is connected. Then, check that the user's permissions have been set with the "%" Login permission. Finally, I go to the virtual machine to view the firewall status, as shown below: Chain RH-Firewall-1-INPUT (2 references) num target prot opt source destination 1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 2 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0 icmp type 255 3 ACCEPT esp -- 0.0.0.0/0 0.0.0.0/0 4 ACCEPT ah -- 0.0.0.0/0 0.0.0.0/0 5 ACCEPT udp -- 0.0.0.0/0 224.0.0.20.udp dpt: 5353 6 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt: 631 7 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dp T: 631 8 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED, ESTABLISHED 9 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt: 22 10 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited 11 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt: 80 12 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt: 5506 I am wondering how the firewall accepts port 5506, but it cannot connect to the database... Then I thought that ssh can be connected. Therefore, port 22 of the firewall must be accessible. That's why port 5506 is not working. I suddenly found that the firewall I set was behind 10 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited. I guess this is the reason, immediately place the enabled port settings on the reject and restart the firewall. Done! Conclusion: when setting a firewall, do not put the accept settings behind the reject, so that you can avoid invalid firewall settings. Reminder: do not forget to restart the firewall!

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.