Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of failed remote connection to mysql

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

How to solve the problem that the remote connection to mysql failed? This problem may be often seen in our daily study or work. I hope you can gain a lot from this question. The following is the reference content that the editor brings to you, let's take a look at it!

The solution to the failure of remote connection mysql: 1, configure firewall, open port 3306; 2, edit my.cnf configuration file, bind IP address; 3, modify user access rights to allow all machines to access; 4, restart mysql.

1. Troubleshoot network or firewall problems

First see if you can ping the remote server, ping 192.168.1.211, if not, it is a network problem. Then, check that the port is blocked by the firewall, telnet 192.168.1.211 3306, and if the connection fails, configure the firewall.

Configure firewall to open port 3306

Vi / etc/sysconfig/iptables-An INPUT-m state-state NEW-m tcp-p tcp-dport 3306-j ACCEPT (allow port 3306 to pass through the firewall) / etc/init.d/iptables restart (restart the firewall to make the configuration effective)

2. Check the MySQL configuration

If the firewall is turned on, telnet still fails. Check the port status of 3306 through netstat:

Netstat-apn | grep 3306tcp6 0 0127.0.0.1 grep 3306tcp6 3306:: * LISTEN 13524/mysqld

Note that this means that 3306 is bound locally. Check the configuration of my.cnf, where you can configure the binding ip address.

Bind-address=addr

No configuration or an IP configuration of 0.0.0.0 means listening for all client connections.

Ps: after I opened port 3306 and checked the MySQL configuration, the telent still failed, but the native telnet was ok. I repeatedly confirmed that there was no problem with the configuration. Later, I mentioned it to our ucloud account administrator, only to know that the ucloud management backend also needs to open port 3306. Pay attention to this with the CVM.

3. Check user access rights

When MySQL creates a user, it specifies a host. The default is 127.0.0.1/localhost, so this user can only access it locally. Other machines accessing with this user account will indicate that they have no permission, and host will be changed to%, which means that all machines are allowed to access.

4. Restart mysql to make the configuration effective.

Thank you for reading! After reading the above, do you have a general idea of how to solve the problem of failed remote connection to mysql? I hope the content of the article will be helpful to all of you. If you want to know more about the relevant articles, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report