nvim-dbee icon indicating copy to clipboard operation
nvim-dbee copied to clipboard

Cannot connect to MySQL databases through SSH tunneling

Open MuresanSergiu opened this issue 1 year ago • 6 comments

I have various connection to databases using SSH tunneling but dbee doesn't seem to be able to connect to them.

If I use this connection string: "root:pass@tcp(127.0.0.1:5000)/database" It fails with error c.db.Conn: Error 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) It somehow changed the 127.0.0.1 to localhost which is not correct.

But if I change it to "root:[email protected]:5000/database" It fails with error adapters.NewConnection: core.NewConnection: adapter.Connect: unable to connect to mysql database: default addr for network '127.0.0.1:5000' unknown

There's nothing that I can do to make this work therefore I cannot use this plugin...

MuresanSergiu avatar Dec 13 '24 09:12 MuresanSergiu

I donot know if this is related to my issue but I cannot connect to any mysql database, I have tried adding it in every way, can someone share an example persistance.json with mysql connections in them?

For me they never show up in the sidebar.

itse4elhaam avatar Feb 25 '25 12:02 itse4elhaam

also having this issue

caliguIa avatar Apr 04 '25 10:04 caliguIa

Just for future reference if anyone else is having this issue. What I've done is in my neovim config is on the VimEnter event, I call vim.uv.spawn('ssh', .......) which opens the ssh tunnel in a background process, that way with dbee I can just ignore anything specific to ssh and connect to the database directly, having been using this setup for a number of months and is working nicely.

For reference here is the dbee.lua file in my config.

caliguIa avatar Jun 05 '25 13:06 caliguIa

thanks for sharing. Inspecting your configuration I don't understand how a SSH tunnel created with command ssh -N ous-staging without port forwarding can route traffic from local nvim to remote SQL server. I can only think about setting up LocalForward in ~/.ssh/config but maybe there's another way

alexrah avatar Aug 10 '25 23:08 alexrah

Yeah so in my ~/.ssh/config I have the following as an example:

Host ous-staging
  User $username
  HostName $hostname
  Port $port
  IdentityFile $pathToPemFile
  LocalForward $port $url:$remotePort

Actual values obfuscated of course. Let me know if you have any other questions, happy to help!

caliguIa avatar Aug 14 '25 07:08 caliguIa

i cant even connect to my local mysql same error is there. is there any workaround?

moeezali2375 avatar Aug 27 '25 14:08 moeezali2375