Bobcares

Lost Connection to MySQL Server at Reading Initial Communication Packet

by | May 7, 2022

Lost connection to MySQL server at reading initial communication packet, is an error we get while connecting to a MySQL database. As part of our Server management services, Bobcares provides solutions for every query.

Let’s take a look at how our Support team handled this situation.

Lost connection to MySQL server at ‘reading initial communication packet

While connecting to a MySQL database, we might run into this error: Lost connection to MySQL server at reading initial communication packet, system error: 0

Lost Connection to MySQL Server at Reading Initial Communication Packet

There appears to be an issue with the firewall, which is preventing outside connections. We should check the firewall rules to see if they are blocking any MySQL connections.

If the firewall isn’t the problem, check the list below to see if we have any of the following:

  1. Verify that MySQL is running on the server’s IP address.
  2. Then, Make sure MySQL is listening on port 3306.
  3. Ensure that the user has permission to connect to the server IP.
  4. Make sure we’re using the correct password for connecting from the host address we’re connecting from if one is required.

Most of the time, MySQL only listens on localhost and does not accept connections from other computers. As a result, we can’t connect from the outside leading to the Lost Connection to MySQL Server error.

In the my.cnf file, look at the bind-address variable. Because it defaults to localhost, only connections from that host will work.

  • Comment out the line: to ensure MySQL listens on all addresses. #bind-address = 127.0.0.1
  • Then restart the server as follows: sudo service mysql restart
  • GRANT ALL PRIVILEGES ON ourDB.* TO 'username'@'OUR_APPLICATION_IP' IDENTIFIED BY 'OUR_PASSWORD' WITH GRANT OPTION;

If we still get the error, then:

  1. Allow applications through the Windows Firewall.
  2. The path to mysql is typically C:/Program Files (x86)/MySQL/bin/mysql, so we’ll need to add it to the list.
  3. Click Apply after marking both private and public networks.

If the IP address is blocked by Firewalld. Use the following commands to grant access: firewall-cmd --permanent --zone=trusted --add-source=OUR_IP/32 firewall-cmd --permanent --zone=trusted --add-port=3306/tcp firewall-cmd --reload

Another solution for the Lost Connection to MySQL Server error is to choose + to add a new connection in the workbench and enter the following information:

  • TCP/IP over SSH is the connection method.
  • xxx.xxx.xx.xx:xx (replace xx with remote SSH server IP and port(optional)) is the SSH Hostname
  • Enter the SSH username
  • At the prompt, we can set a password.
  • MYSQL Localhost or 127.0.0.1 is the hostname.
  • Port:3306 MYSQL Server
  • At the prompt, we can enter a password or add a new one.

Then, check the connection. If it is successful, click OK. Also, to ensure MySQL Server connections are not denied:

1. Check /etc/hosts.deny and make sure it does not contain:

ALL: ALL: DENY
mysqld: ALL: DENY

2. If needed, add the following to /etc/hosts.allow:

makefile

mysqld: ALL

3. Or to allow only specific networks, use:

makefile

mysqld: 192.168.1.0/255.255.255.0

4. Note that when connecting to MySQL Server:

  • localhost uses the UNIX socket.
  • 127.0.0.1 uses TCP/IP networking.

These two are not interchangeable.

If nothing else works, flush the privileges. mysql> FLUSH PRIVILEGES;

[Looking for a solution to another query? We are just a click away.]

Conclusion

To sum up, our Support team was successful in resolving the error: Lost connection to MySQL server at reading initial communication packet with the above steps

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF