The first thing to do if you want to connect to PostgreSQL on your Raspberry is to configure PostgreSQL to accept remote connections:
- Allow incoming/outgoing connections setting firewall rules with
iptables
:
$ iptables -A INPUT -i eth0 -p tcp --dport 22 -m state --state NEW, ESTABLISHED -j ACCEPT
$ iptables -A OUTPUT -o eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT$ iptables -A OUTPUT -o eth0 -p tcp --dport 22 -m state --state NEW, ESTABLISHED -j ACCEPT
$ iptables -A INPUT -i eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT - Edit
pg_hba.conf
file, insert the following raw:
# TYPE DATABASE USER ADDRESS METHOD
host all all XXX.XXX.XXX.XX/32 md5
WhereXXX.XXX.XXX.XX
is the IP address of the remote machine. - Edit
postgresql.conf
file, insert the following raw:
listen_addresses = '*'
to allow listening from all sources.
…then perform the connection with pgAdminIII
The easiest way to connect with a PostgreSQL server based on a Raspberry PI from a remote machine is to use pgAdminIII. This is a graphical client that can be easily installed on a Debian machine with
sudo apt-get install pgadmin3
Once is launched, select File
from the menu and then select Add server
:
fill the fields of the connection form: host name, port number, user and database. If Store password
is ticked, credentials are stored in the ~/.pgpass
file.
Once the connection is stored, can be used just with a mouse click. Then, Raspberry PI database can be explored with the pgAdminIII browser.
Pingback: Connecting to PostgreSQL on Raspberry via psql | Raspberry PG
Excellent submit, very informative. I ponder why the opposite specialists of this sector do not understand this. You must proceed your writing. I am sure, you’ve a huge readers’ base already!|What’s Taking place i’m new to this, I stumbled upon this I’ve found It positively helpful and it has aided me out loads. I’m hoping to give a contribution & help other users like its aided me. Great job.
It¡¦s actually a cool and helpful piece of information. I¡¦m glad that you simply shared this helpful info with us. Please keep us informed like this. Thank you for sharing.
Thank you for some other wonderful post. Where else may anyone get that kind of information in such an ideal approach of writing? I have a presentation subsequent week, and I am at the search for such information.
Its like you read my mind! You appear to know a lot about this, like you wrote the book in it or something. I think that you could do with a few pics to drive the message home a bit, but other than that, this is wonderful blog. An excellent read. I will certainly be back.
I have learn several excellent stuff here. Definitely price bookmarking for revisiting. I surprise how so much attempt you place to create this sort of magnificent informative website.
I’m now not sure the place you are getting your information, however great
topic. I must spend a while studying more or working out more.
Thanks for fantastic info I used to be on the lookout for
this information for my mission.
Thanks for finally talking about > Connecting to PostgreSQL on Raspberry
via pgAdminIII | Raspberry PG < Liked it!