Configuring Postgres Ubuntu

Following our previous post, we now explain how to access Postgres through the command line.

First a modification has to be made in the config files:

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

uncomment the line and put

local all username md5

Where username is the user you created

then restart:

sudo /etc/init.d/postgresql restart

now you will be able to access:

psql database_name username

and you will be requested to enter the password

Advertisements

How to install Postgres 9.1 in Ubuntu 12.10

Follow this guide:

https://gist.github.com/andremendonca/5991965/raw/73d3f88aa53d6ef85443c7c24ecc302713eb129d/install+postgree+on+ubuntu

# STEP 1: VERIFY THAT YOU DO NOT ALREADY HAVE POSTGRESQL INSTALLED ON YOUR SYSTEM
ps ax | grep postgres

# STEP 2: INSTALL POSTGRESQL ON YOUR SYSTEM
sudo apt-get update
sudo apt-get install postgresql-9.1

# List All Postgres related packages
dpkg -l | grep postgres

# * No PostgreSQL clusters exist; see “man pg_createcluster”
# STEP 2.1: CREATES A NEW POSTGRESQL SERVER CLUSTER
# http://serverfault.com/a/234993
pg_lsclusters
pg_createcluster 9.1 main –start

# STEP 2.2: change user to the PostgreSQL user
sudo su – postgres

# STEP 3: CONFIGURE YOUR POSTGRESQL PASSWORD
#IF changed to user Postgre already
psql -d postgres -U postgres