Question

How to connect to my sql database via sqlworkbench

I am very new to digital ocean and also Linux VMs, I am helping a colleague who would like to access a database, the original person who created the site/database etc, is no longer around.

I have so far managed to get into the vm and find all the code for the website, but I am at a loss on how we can actually connect to the database, there are a couple of changes they would like to make which could easily be done with access to the database.

The application is an ASPNET application and in the settings file, I have the connection string,

“User ID=adi_net;Password=*********;Server=localhost;Port=5432;Database=adi_net3;Integrated Security=true;Pooling=true;”

How is the best way to connect to this database? I have sqlworkbench installed on my own machine, is there a way to connect to it from this?

Thanks


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

KFSys
Site Moderator
Site Moderator badge
September 5, 2022

Hi @dannyjebb,

You can connect to the Database from the Droplet itself.

First, see what Database it’s being used(it’s not that essential but it’s good to know for future use). To see that, SSH to the Droplet and type in:

  1. netstat -tulpen | grep 5432

What running on that port should be the DB.

Now, in order to connect to it with SQLworkbench, you need to allow your IP address to access this port - 5432.

If you are using UFW, here is the command:

  1. sudo ufw allow from XXX.XXX.XXX.XXX to any port 5432

If you are using IPTABLES, the command is:

  1. sudo iptables -A INPUT -p tcp -s XXX.XXX.XXX.XXX/24 --dport 5432 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
  2. sudo iptables -A OUTPUT -p tcp --sport 5432 -m conntrack --ctstate ESTABLISHED -j ACCEPT

In both commands, you’ll need to replace XXX.XXX.XXX.XXX with your actual IP address you are connecting from.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel