$ cat "

Getting Started with Postgres on Ubuntu

"

I just tried to get postgres working under Ubuntu 12.10 and had to google a few things, so here is a quick note of how to get it running:

Install postgres:


apt-get install postgresql-9.1

Change password for the postgres user:


sudo passwd postgres

Open the file /etc/postgresql/9.1/main/pg_hba.conf and change the line:


 local   all             all                                     peer


to


 local   all             all                                     md5

Create a database user (-P for password prompt):


sudo -u postgres createuser -P someusername

Create a database (-O specifies the owner):


sudo -u postgres createdb -O somedatabasename

Restart postgres:


sudo service postgresql restart

Start setting up the new database with the new user:


psql -U someusername -d somedatabasename

When in the psql terminal use \? to list all available commands and \q to exit.

Written by Erik Öjebo 2012-11-16 08:28

    Comments