Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phpstorm. Can't access to mysql server through SSH tunnel (connection is closed by foreign host)

Sorry for the mistakes I've made, I'm not Englishman.

I use vagrant to deploy remote virtual machine as my web server which is configured to use :private_network, ip: "192.168.10.10". On the machine is installed Nginx, PHP, MariaDB etc.

Recently, I start to use phpstorm as my main IDE. Now I'm trying to configure access to remote database server, but I fail. Please, see the screens for additional information.

To check the ssh and mysql server access I tried the following:

$ ssh [email protected] #ok
$ mysql -h localhost -P 3306 -u root -p #ok (it's run on the remote machine)
$ telnet -l root localhost 3306 #also run on the remote machine,
the output:
5.5.5-10.0.7-MariaDB-1~precise-log%how)b3s?�O|G*=63=yi#qmysql_native_password
Connection closed by foreign host.

MariaDB configuration file seems to be ok. I only changed bind-address in /etc/mysql/my.cnf to 0.0.0.0.

I tried to set different configuration data, like: localhost:8080 instead of 169.168.10.10:80, double check password in SSH tunnel window, but nothing. Please, help me..

enter image description hereenter image description here

like image 681
Timur Fayzrakhmanov Avatar asked Jan 11 '23 07:01

Timur Fayzrakhmanov


1 Answers

In my case I had to enable TCP forwarding in the ssh configuration of the remote host:

AllowTCPForwarding yes

And also I had to grant all privileges on users connection from 127.0.0.1 (instead of just from 'locahost'):

grant all privileges on some_db.* to [email protected] identified by 'secret';
like image 50
Michiel Roos Avatar answered Jan 23 '23 04:01

Michiel Roos