Can't connect to mysql using ssh tunnel


This is going to be something stupid, but I've wasted way too much time on this.

On my VPS, it seems I can no longer connect to mysql using the account's username. I know I used to be able to do this, and I can still do this on my dedicated. But for the life of me I can't get it to work anymore.

I am using navicat light and using an ssh tunnel to connect so there is no need to enable remote mysql access in cpanel. I'm even tried a root tunnel (vs a user account ) but it won't connect. The tunnel connects (based off the ssh login emails I get), but not mysql to localhost. I've tried from two different computers, with two different IPs to several different cpoanel accounts. I can no longer connect to any of them. I've tried using passwords for ssh, I've tried using keys for ssh. I have php scripts that connect fine with the mysql /account passwords I'm using.

I can use putty to ssh from either computer no issues. I can connect to mysql from a root ssh using the cpanel account credentials via command line.

In the same instance of navicat, I can connect to my dedicated server using ssh tunnels with no issues from both comptuers/IPs.

Is there anything in cpanel on my VPS that could be blocking mysql somehow?



Active Member
Just a shot, if you're working on a newer server, it's probably MariaDB and not MySQL. Try Navicat for MariaDB instead. Maybe that's the issue? If not, are you getting any detailed errors?


Staff member
I wouldn't foresee anything VPS side that could be blocking it. I'd double check /var/lib/mysql/hostname.err to see if anything is being logged there on connection attempts. As long as you can connect via SSH with mysql -u username -p then it should work the same.

We can always dig a bit deeper in the logs but it'll be a bit more difficult for us to replicate this since we don't really use Navicat here but if you need extra help let us know.


I'm just getting a "Lost connection to MySql server at 'reading initial communication packet',. system error:0"

But if you try to connect again to the same DB, I get "cant connect to MySql server on 'localhost' (10061)." Eventually the first error comes back.

I'm sure these connections used to work. I feel like the only major thing to happen to that VPS was the recent security updates.

There was nothing of note in the err file.

So I had restarted mysql before, but now I rebooted the server and it appears it's working again! Weird.

Guess I should have tried turning it off an on again first. Duh.


New Member

It's need that you have to start mysql service, it may be down, and allow mysql port 3306 in firewall/iptables.
it will connect on your local system via those credentail which you have.
In alternative you have to reset the password of root user. and it was last one step.