A slight return to Postgres

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:

  1. First install postgres by entering ‘apt-get install postgresql’ in a bash-session/terminal
  2. We need to properly initialize it and I would recommend to add your login user to Postgres: sudo -u postgres createuser -D -P arthur
  3. Optionally, create a new database: sudo -u postgres createdatabase -O username whateveryouhavefordatabasename
  4. Open up pg_hba.cfg (sudo vi /etc/postgresql/9.1/main/pg_hba.conf).
  5. 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

  6. Open up postgresql.conf and set listen_addresses = ‘*’ properly (* means that postgres will listen to all ip-address as defined in networking)
  7. Restart postgresql
  8. 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

This entry was posted in Ordinateurs, Programming and tagged , , . Bookmark the permalink.