Tuesday, April 16, 2024
99
rated 0 times [  99] [ 0]  / answers: 1 / hits: 176627  / 2 Years ago, sat, january 1, 2022, 2:35:13

I need to access a postgresql database from a remote machine on a VPS at DigitalOcean running 12.10 and postgresql 9.1.



How do I do this? I noticed port 5432 is closed, how do I open this?


More From » remote-access

 Answers
7

To open the port 5432 edit your /etc/postgresql/9.1/main/postgresql.conf and change



listen_addresses='localhost'


to



listen_addresses='*'


and restart your DBMS



invoke-rc.d postgresql restart


now you can connect with



$ psql -h hostname -U username -d database


if you are unable to authentify yourself, then you need to give your user access rights to your database



Edit your



/etc/postgresql/9.1/main/pg_hba.conf


and add



host all all all md5


(This is for a wide open access. For stricter control, consult the pg_hba.conf documentation and adjust according to your needs).



Hereafter you need also a reload



invoke-rc.d postgresql reload


I don't need to mention that this is a basic configuration, now you should think about modify your firewall and improve the security of your DBMS.


[#26917] Saturday, January 1, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jokaned

Total Points: 315
Total Questions: 116
Total Answers: 119

Location: Somalia
Member since Mon, Feb 27, 2023
1 Year ago
;