Connecting Jetbrains DataGrip to a remote database via SSH - mysql

I have an AWS Lightsail instance running the Bitnami configuration for Ubuntu 16.04.5 LTS and PHP7.
I can connect the the MySQL database using phpMyAdmin on the server via an SSH Tunnel. But when I try to configure DataGrip for SSH access to the database I receive the error message "Host '127.0.0.1' is not allowed to connect to this MySQL server".
When I remove "localhost" from the host field of the General tab then I receive the error "ExecutionException: SSH: Unable to find host/port in URL".
The following test and response appears to show a successful connection to the port:
cat < /dev/tcp/###.###.###.###/22
SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.6
I'm using keypair auth. Both the user name and the Private key file are the same used for the ssh tunnel when running phpMyAdmin.
Not sure what to try next. Any help appreciated.

Related

Error when using the command line terminal to connect to the Azure MySQL server

I'm using the command line prompt on my Windows computer to connect to my Azure MySQL server.
hostname=flashguard.mysql.database.azure.com
username=damiboyflashguard123
port=3306
I entered following on my cmd
mysql -h flashguard.mysql.database.azure.com -P 3306 -u damiboyflashguard123 -p
and entered the password. Then I'm getting following error,
ERROR 2003 (HY000): Can't connect to MySQL server on
'flashguard.mysql.database.azure.com:3306' (10060)
By the way I checked my firewall settings, and it shows firewall is approving on 3306 port requests as follows.
I installed MySQL client in my local machine and tried connecting to Azure mySQL client via command line terminal and was connected successfully:-
ERROR 2003 (HY000): Can’t connect to MySQL server on
‘flashguard.mysql.database.azure.com:3306’ (10060)
Make sure your MySQL server name with username and password does not have any syntax missing or spelling errors. Add your local machine’s IP to the allowed list of Azure MySQL servers like below:-
Make sure your MySQL server is in a ready state and also try to connect to your MySQL server from your Azure Portal to check the connectivity.
Verify your connecting string from Azure Portal like below:-
I ran the above command in my local machine’s command line terminal and I got connected to the azure MySQL server successfully like below:-
mysql -h server-name.mysql.database.azure.com -u xxxxconuser -p xxxxxxxxxn#123
Output:-
When I removed the Client IP from the azure MySQL Networking tab, I got the same error code as yours, refer below:-
Error:-
Verify if you’re connected to any VPN that is restricting you from connecting to the MySQL server on Azure.

Connect MYSQL DB on DigitalOcean MYSQL WorkBench

I'm trying to connect MYSQL WorkBench to a db on digitalocean droplet.
I follow the link:
https://www.digitalocean.com/community/tutorials/how-to-connect-to-a-mysql-server-remotely-with-mysql-workbench
But still getting the following error:
Failed to Connect to MySQL at localhost:3306 through SSH tunnel at root#xxx.xxx.xxx.xxx with user root
Cannot open SSH Tunnel: Connection refused
Upload your SSH key to gain access

"Can't connect to local MySQL Server" using SSH tunnel

Starting an SSH tunnel to MySQL so MySQL Workbench can connect to the remote DB using the following command:
ssh -L 3306:localhost:3306 <username>#<domain> -N
MySQL Workbench is able to connect without issue doing this.
I was also trying to spin up a local copy of the Django application and connect to the remote test DB and I get met with:
django.db.utils.OperationalError: (2002, 'Can\'t connect to local MySQL server through socket \'/var/run/mysqld/mysqld.sock\' (2 "No such file or directory")'
Looking at the Django settings, everything looks correct. Just seems like Django is ignoring the tunnel despite using the same port. Django is in virtualenv so wonder if something there might be causing it.
Any suggestions?
I had to change the DB connection string in the settings.py to 127.0.0.1 instead of localhost.

MySQL: Unable to connect using TCP/IP over SSH

We have an EC2 and RDS instance on Amazon Web Services. I usually first connect to the server using Putty and then access the database through a tunnel from my localhost.
I am now trying to directly connect to the database using TCP/IP over SSH, but get the following error. I am able to connect other applications such as FileZilla directly without creating any tunnels, but not able to connect MySQL. Please advise. There is no entry in known_hosts file.
Error:
[Window Title]
MySQL Workbench
[Main Instruction]
Failed to Connect to MySQL at database.aws-server.rds.amazonaws.com:3306 through SSH tunnel at username#100.100.100.100:22 with user username
[Content]
Cannot open SSH Tunnel: Error connecting SSH tunnel: The host 100.100.100.100 fingerprints mismatch.
Expected key: hjd83iuwe98jdoiw8euoqeuo83eqe308
Server sent: 8ru84ru8ur984u8djc0938y4jddj398e
Please verify if it's correct.
To continue, delete entries for the host from the C:\Users\<USER>\AppData\Roaming\MySQL\Workbench\ssh\known_hosts file.
[OK]
I am connected to my rds database using the following script-
ssh -L 3406:database.aws-server.rds.amazonaws.com:3306 -i username#100.100.100.100
this command will create a tunnel on your local machine port 3406 of the mysql's default port 3306.
after that you can connect at 3406 port in your application
ssh-keygen -f "C:\Users<USER>\AppData\Roaming\MySQL\Workbench\ssh\known_hosts" -R "database.aws-server.rds.amazonaws.com"

Cannot Connect to Database Server MySQL Workbench Tunnel Error

Every time I try to connect to my mySQL on mysql workbench, it gives me this error message saying:
Your connection attempted failed for user 'root' from your host to server at http:x.x.x.x:3306: Cannot open SSH Tunnel:Error connecting SSH tunnel:Error Connecting to SSH server Error 11004 get addrinfo failed
I think you could get solution here: http://quintagroup.com/services/support/tutorials/mysql-linux
or follow this steps:
Open putty and accept the certificate of the server
hostname should be localhost ( in order to use local socket and not http conection)
local port should be something like 33010 not 3306
local port is the conection back port used by the plink and has nothing to do with mysql ports