1

I've a database with credentials which is my website's database.

Is there a way from my local machine to access this database using IP, User and Password?

Using Ubuntu 18.04, phppgadmin and PostgreSQL.

Thanks.

  • Do you have ssh access to the server running the database? – pLumo Apr 8 '19 at 11:45
1

Yes, if you have root access to the server.

Warning: this method not recommended if you don't have a static IP address because you would need to open up your database to the world, which is disabled by default as a security measure, better use the method below.

If you want to ignore my warning:

In postgresql.conf:

listen_addresses = '*'
#or
listen_addresses = 'your-static-ip'

In pg_hba.conf add this to allow remote connections from any IP:

host    all             all              0.0.0.0/0                       md5
#or
host    all             all              your-static-ip/32               md5

Recommended method:

If you can connect to the server with ssh, there is a better/safer method:

Create a local port forwarding tunnel first:

ssh -L 5432:127.0.0.1:5432 your-server.com
#or
ssh -L 5432:localhost:5432 your-server.com

This will forward a local port via ssh to a port on your server. Then you can connect to that port using localhost as host.

| improve this answer | |
0

Very probably not.

The provider that hosts the website will have restricted access to the database to requests coming from the web server. All other requests are ignored. Otherwise, they would be under a constant attack from hackers wanting to break into the database.

So the only programs that can access the database are those that run on your web server. Usually that means PHP programs, like those that your website is built from. Credentials to access the database will be stored in a config file. Additionally, as a service, hosting companies usually provide PHPMyAdmin (in the case of MySQL) or PHPPGAdmin (for PostgreSQL). With the latter, you need to provide database credentials yourself.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.