Vim DB client: vim-dadbod-ui connection via SSH tunnel
I’m using vim-dadbod-ui as my MySQL client.
I was trying to connect to RDS via SSH tunnel, finally figure out how to do that.
1. Create an SSH tunnel
1 | ssh -oStrictHostKeyChecking=no -i ~/.ssh/your-server-key.pem \ |
This command will forward your local connection in port 3307 to the RDS in port 3306.
The &
to make it run on background.
2. Add a connection to the vim-dadbod-ui client
Edit the file ~/.local/share/db_ui/connections.json
1 | [{ |
The first connection is my local DB, and I use port 3306.
Since the port 3306 already in used, I map 3307 to the SSH tunnel in step 1,
in the second connection I just refer to 127.0.0.1
, but with port 3307.
The command is equivalent to
1 | mysql -h 127.0.0.1 --port 3307 -u someuser -p --ssl-mode=DISABLED |
(Some how I need the --ssl-mode=DISABLED
, otherwise it throws error)
In case if you need to add more remote connection, you can use the port 3308 or any other unused port.
3. Open the client
1 | vim +DBUI |
Start using it now