Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSH Tunnel MySQL Connection with socket-connection via PhpStorm

By default, Database Manager from PhpStorm works well. But currently on a special Provider (1u1.de) I have some trouble to got this work.

I can connect to the Provider via SSH. If I want to connect to MySQL database, I have to use:

mysql --host=localhost --user=dbo123123123 -S /tmp/mysql5.sock --password='123123123';

That's works well via CLI on Server, but I didn't find a way to connect via PhpStorm to this Database.

For me it seems that the "socket-connection" may be the Problem. Does anybody have a clue how to got this to work?


Part of the Solution (?!):

Maybe a first part of an solution, I found that you be able to forwarding an Socket to your local pc as own socket this way:

ssh -nNT -L $(pwd)/yourLocal.sock:/var/run/mysqlREMOTEMYSQL.sock user@somehost

Source of Information

This show me, that the Socket is established:

netstat -ln | grep mysql unix 2 [ ACC ] STREAM LISTENING 3713865 /myFolder/mysql5.sock

But I'm still unable to connect to this Socket with:

mysql -h localhost --protocol=SOCKET -u'username' -p'mypassword' -S /myFolder/mysql5.sock

Got this Error:

ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 95 "Operation not supported"
like image 829
suther Avatar asked Nov 18 '25 16:11

suther


1 Answers

ssh -L /tmp/mysql.sock:/var/run/mysqld/mysqld.sock sshuser@remotehost

and then

mysql -h localhost --protocol=SOCKET -u'username' -p'mypassword' -S /tmp/mysql.sock

seems to work fine for me

like image 161
Zayin Krige Avatar answered Nov 21 '25 07:11

Zayin Krige



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!