Tuesday, 3 March 2015

Install Postgresql in ubuntu 14.04.

Open terminal (ctrl + t) and paste these command one by one

sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
  

Using PostgreSQL Roles and Databases

By default, Postgres uses a concept called "roles" to aid in authentication and authorization. These are, in some ways, similar to regular Unix-style accounts, but Postgres does not distinguish between users and groups and instead prefers the more flexible term "role".
Upon installation Postgres is set up to use "ident" authentication, meaning that it associates Postgres roles with a matching Unix/Linux system account. If a Postgres role exists, it can be signed in by logging into the associated Linux system account.
The installation procedure created a user account called postgres that is associated with the default Postgres role. In order to use Postgres, we'll need to log into that account. You can do that by typing:

sudo -i -u postgres 

  You will be asked for your normal user password and then will be given a shell prompt for the postgres user.
You can get a Postgres prompt immediately by typing:

psql 

  You will be auto-logged in and will be able to interact with the database management system right away.
However, we're going to explain a little bit about how to use other roles and databases so that you have some flexibility as to which user and database you wish to work with.
Exit out of the PostgreSQL prompt by typing:

\q 

  You should now be back in the postgres Linux command prompt.