I am getting error:
"Lost connection to MySQL server at 'reading initial communication packet, system error: 0"
while I am going to connect my db.
If I am using localhost everything is working fine. But when I am using my live IP address like below, it's getting error:
mysql_connect("202.131.xxx.106:xxxx", "xxxx", "xxxxx") or die(mysql_error());
The apache firewall blocks the ip address. so to give access, use these commands:
firewall-cmd --permanent --zone=trusted --add-source=YOUR_IP/32
firewall-cmd --permanent --zone=trusted --add-port=3306/tcp
firewall-cmd --reload
I faced the same problem. I checked and tried to set AllowTcpForwarding Yes but it was missing in my sshd_config so no help.I didn't change sshd_config or my.cnf. Make sure the ssh hostname is NOT the same with the mysql hostname(use localhost).
In workbench, choose + to add new connection and set the following:
Test connection. It should be successful then hit OK.Viola!
I just set up mysql on a windows box. I got the OP's error when trying to connect with the Navicat MySql client on the same box. I had to specify 127.0.0.1 as the host, and that got it.
localhost, or the servers actual ip address both did not work.
in my case, I had ALL: ALL in hosts.deny. Changing this to ALL: PARANOID solved my problem when connecting over ssh
When connecting to Mysql remotely, I got the error. I had this warning in
/var/log/mysqld.log
:I just added this line to
/etc/hosts
file:Problem solved! Not using
skip-name-resolve
caused some errors in my local app when connecting to MySQL.I had identical problem. To fix it I just changed host from localhost:3306 to just localhost. So error may acour when You sepcify unproper port for connection. It's better to leave it default.