Years ago, I used to set up postgres on Debian servers. For a couple of test, I had to install Postgres somewhere: Installing on Windows is generally a breeze, but not needing the third-party tools, I decided to go back to Linux and install the database server on my Ubuntu box. While I didn’t have issues with importing test data/databases, there were minor things that had me briefly stumped. So, to install Postgres on Ubuntu and other Debian flavours, here we go:
- First install postgres by entering ‘apt-get install postgresql’ in a bash-session/terminal
- We need to properly initialize it and I would recommend to add your login user to Postgres: sudo -u postgres createuser -D -P arthur
- Optionally, create a new database: sudo -u postgres createdatabase -O username whateveryouhavefordatabasename
- Open up pg_hba.cfg (sudo vi /etc/postgresql/9.1/main/pg_hba.conf).
- Change the following lines properly (use trust):
# IPv4 local connections:
host all all 127.0.0.1/32 trust
host all all 192.168.2.0/24 trust - Open up postgresql.conf and set listen_addresses = ‘*’ properly (* means that postgres will listen to all ip-address as defined in networking)
- Restart postgresql
- Connect to postgres using the psql client: psql -U arthur -h localhost -d whichever database
The official postgres site has demo databases (or rather links to them): they are around this url