Hi, I am having issues accessing MySQL through n8n.
I looked through the forum for someone with similar issues as it could be my lack of skills.
I can access it through the terminal but for some reason it doesn’t work on n8n.
So I understand it correctly that you create an SSH tunnel and so redirect the local traffic to the remote MySQL server? In this case should the “Host” in the credentials not be “localhost”?
The MySQL host is different from the SSH host.
I first connect to an SSH IP e.g [email protected] once I have access to 11.111.111.111 I can then request access with;
~$ mysql -u User_Name -p -h xxxxxxxxxxxxxxx-1.rds.amazonaws.com
Honestly do not have much experience in this. But what an SSH tunnel does is to redirect all local traffic from a local port to another or the same port of an external server.
So as described here:
And there it then also says to connect now to 127.0.0.1:3336.
If there are totally different servers and if sending traffic to the port of the SSH server does not end up on the MySQL server I honestly do not know how to connect to it. Again have sadly no experience. But is also not a directly to n8n related question, rather a more generic one. So I guess if you do some more googling you find a solution that would also work with n8n.
Thanks Jan, fully understandable. I was most curious about the Mysql node on n8n. Perhaps the issue is there on how it forwards its requests and perhaps one could add the SSH tunneling in like Sequel pro to make it easier.
I’m looking for this feature too, because for run remote commands such as mysql querys in another host is secure regarding access another environment to use some workflows.
In my case I`m creating workflow to access management, using JIRA Service Desk as input, to give access creating users in MYSQL instance and give access in databases.
Did someone manage to get this working. I am currently looking for a solution to this problem as well. Would need to be able to connect to our MySQL server over a SSH connection.
A possible solution might be to create the SSH tunnel first then do the connection that is how I would do it from my desktop.
I have never tried it in n8n but in theory adding the ssh client to the docker image then making the tunnel in an execute command node with -L and just sending the output to /dev/null would then allow the MySQL node to work by connecting to localhost and whatever port gets directed.
It would cleaner to have this in the node directly though.
I don’t thing it would work. How MySQL node would know the host? For the credentials at the Host field you have to specify localhost or 127.0.0.1. But to do this there must be a connection from n8n to the host via a ssh tunnel or a VPN outside the n8n container.
To work the same concept as other MySQL IDEs has to be applied that they allow to use SSH Tunnel via the app.
The Node would connect to localhost, So with an SSH tunnel you open an SSH session between your machine and the remote server and you forward a local port to the port you want on the remote side.
You would be setting up your local port 3307 to be the remote host and port of 127.0.0.1:3306 so in your MySQL node it would point to localhost and port 3307 and with the magic of the tunnel it will translate that to the localhost of the remote machine and port 3306.
Assuming the tunnel is opened in the container if you are using one it should do the job, If you are using npm instead in theory it is a lot easier as you just need to make the tunnel connection on your machine.
You would need to start the tunnel from inside the container for best results, If you are trying it on the docker host maybe using ssh -N -L 172.17.0.1:3307:127.0.0.1:3306 would do the job.
I have given this feature request an up vote. @Jon 's solution works perfectly on a local Docker install, but not on the Cloud (as far as I can think of) … unless I would be able to setup/configure this in my instance? I am in the process of migrating all the critical production processes to the Cloud and leave my local Docker as development and fall-back environment. So a proper ‘MySQL over SSH’ connection would be ideal for that.
You got it, The workaround won’t work on Cloud at the moment. I am not sure how much work would be involved in adding in the SSH option to the node but I suspect it would involve having to create an SSH tunnel in the node first as I don’t like the package we use has it an option to just enable.