Problems while establishing a remote connection to MySQL using DataGrip

database connectionremote-access

I'm new to these things, I'm familiar with the command lines and the SQL commands. I am currently working on a MySQL database that I have installed on a Linux server (Ubuntu Server) remotely outside my city.

In the office I use a macOS machine to develop applications and manage the server. Currently I move data to and from my computer and server using the scp command, with which I load any SQL scripts to update the remote database and so on.

We are recently using DataGrip, I would like to configure it, but I can not.

Can someone kindly explain to me a simple configuration procedure?

Currently I know:

  • the listening port used by MySQL, which is 3306

  • the IP address of the remote server

  • the login username and password

I enter this information, but DataGrip can't connect. How can I check what's wrong? How can I understand what I'm doing wrong?

Sorry for my ignorance.

I tried to connect in two ways, as shown in the following two figures.

enter image description here
enter image description here
enter image description here

I tried also through terminal:

enter image description here

Best Answer

Is MySQL listening on the public IP of your remote server? Is the 3306 port on the public IP of the remote server reachable from outside?

Most likely no, and that's good.

What you need to do is tell DataGrip to open a ssh port forward to the server (a tunnel) and then open a connection to MySQL.

It looks like DataGrip fails to access the server via ssh.

Try to ssh into your server from OSX like this:

 ssh -L 3306:localhost:3306 your-ssh-user@your-remote-host

If you don't get any error, enter the following info under SSH/SSL tab:

Proxy Host: your-remote-host
Proxy User: your-ssh-user
Proxy Password: your-password

Then click 'Test connection' and verify that you don't get any error.

Note that your credentials to access the server via ssh are different from your MySQL credentials!