Lost connection to MySQL server at 'reading initial communication packet', system error: 0

Posted March 31, 2019 68.6k views


I saw many Q&As regarding this problem.
Here is what I did for troubleshooting:

  • I saw that the server is listening on the SQL default port:
    netstat -ntlp | grep 3306
    tcp6 0 0 :::3306 :::* LISTEN 3092/mysqld

  • /etc/mysql/my.cnf was empty

  • IpTables was empty.

  • telnet <My IP> 3306 -> resulted in correct manner

I feel a little bit clueless… If someone can help I would be gracious. Also, I would be happy to understand exactly what does this error say, b/c if I try to connect with my MySQL workbench to some random IP I get a different error.

Many Thanks,

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

This is confusing indeed. Error 0 means success.

$ perror 0
OS error code   0:  Success

Can you add this to your [mysqld] section in my.cnf:

bind-address =

Restart MySQL. Can you also post the output of this command from your workstation (not server):



  • Hi @unixynet,

    Thanks for your reply.

    First of all thanks to your reply, I understood that I am opening an imaginary file and I was opening my.conf in the wrong place.

    I added the bind-address = and restarted mysql.

    When I did telnet <ip> 3306 from my pc I get an empty screen (which is from my understanding a good thing)

    Still, the problem is persistent.


Had same problem and tried this and it worked;

CREATE USER username@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' ;
flush privileges;