Can't connect to MySQL via SSH

#1
Hi.
I'm using Navicat (for MariaDb) to work on databases. I connect to these databases via a SSH tunnel.
This works fine for databases that are on Apache/Debian servers but I can't connect on those on CentOS/Litespeed Enterprise ones. I keep getting this error:

2013 - Lost connection to MySQL server at 'reading initial communication packet', system error: 0 "Internal error/check (Not system error)"

The SSH connection works fine so the problem is between SSH and the MySQL server. As far as I can tell, this server is set up the same way the others (on Debian) are so I don't know whether there is something particular to LiteSpeed or if it's a CentOs (7) thing (I'm more used to Debian).
Thanks for any pointer and Happy New Year to all.
 

Pong

Administrator
Staff member
#4
LiteSpeed is web server, mysql is database, they have no relationship. focus on the database itself. database error has nothing to do with LiteSpeed.
 
#5
Usually it indicates network connectivity trouble and you should check the condition of your network if this error occurs frequently. It might be because the MySQL server is bound to the loop-back IP (127.0.0.1 / localhost) which effectively cuts you off from connecting from "outside". If this is the case, you need to upload the script to the webserver (which is probably also running the MySQL server) and keep your server host as 'localhost' Another common cause of connect timeouts is the reverse-DNS lookup that is necessary when authenticating clients. It is recommended to run MySQL with the config variable in my.cnf:

Open mysql configuration file named my.cnf and try to find "bind-address", here replace the setting (127.0.0.1 OR localhost) with your live server ip (the ip you are using in mysql_connect function).

Restart service by command : service httpd restart

GRANT ALL PRIVILEGES ON yourDB.* TO 'username'@'YOUR_APPLICATION_IP' IDENTIFIED BY 'YPUR_PASSWORD' WITH GRANT OPTION;
 
Top