MySQL server 3306 port cannot be remotely connected to resolve

Source: Internet
Author: User
Tags iptables mysql view

1. Network detection
1) Ping the host can;
2) Telnet host 3306 port can not;
Telnet host 22 port can be;
The description is not related to the native network;


2. Port detection
1) netstat-ntpl |grep 3306
TCP 0 0::: 3306:::* LISTEN-
2) Netstat-ntpl |grep 22
TCP 0 0 0.0.0.0:22 0.0.0.0:* LISTEN-
You can see that port 22 listens to all addresses, and 3,306 listens to native addresses (bound to local), so it cannot be accessed remotely. Modify MY.CNF in bind-address=0.0.0.0
For ports that only allow native access, there are two places enabled, one is firewall enabled 3306, and the other is MySQL configuration binds the machine address.


3. Firewall detection
1) iptables--list view;
2) Open firewall 3306 port
Vi/etc/sysconfig/iptables
-A input-m state–state new-m tcp-p tcp–dport 3306-j ACCEPT (Allow 3306 ports through the firewall)
/etc/init.d/iptables Restart (Restart the firewall for configuration to take effect)
3) or close the firewall directly; Reference: http://blog.csdn.net/fjssharpsword/article/details/50973283
CentOS 7 is modified after firewall
Systemctl Start Firewalld# Start,

Systemctl enable FIREWALLD # boot up

Systemctl Stop Firewalld # off

Systemctl Disable FIREWALLD # Cancel boot boot



4. mysql configuration file check
Check the configuration of the MY.CNF, BIND-ADDRESS=ADDR can configure the binding IP address.
No configuration or IP configuration of 0.0.0.0 indicates that all client connections are listening.
#ps-aux | grep mysql view process ID is 3340
#ll/proc/3340 See the process program, find the configuration file
Or #which MySQL to find the program path


5. mysql User access rights
Go to MySQL Database
$mysql-U root-p
>use MySQL;
>select host,user from user;
MySQL to build a user will specify a host, the default is 127.0.0.1/localhost only native access;
Other machines with this user account access will prompt for no permissions, the host is changed to%, which means that all machine access is allowed.

MySQL server 3306 port cannot be remotely connected to resolve

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.