Postgre SQL Installation In Linux
This tutorial will guide you step by step for the installation of postgres in linux distribution .
Installation
Ubuntu's default repositories contain Postgres packages, so we can install them without a hassle using the apt packaging system. Since we haven't updated our local apt repository lately, let's do that now. We can then get the Postgres package and a "contrib" package that adds some additional utilities and functionality: sudo apt-get update sudo apt-get install postgresql postgresql-contrib

Access PostgreSQL command prompt
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 -u postgres psql postgres

\q
in the psql prompt return back to the Terminal. Set “postgres” user password
Login to postgre sql prompt, sudo -u postgres psql postgres
and set postgres password with following command: postgres=# \password postgres

postgres=# CREATE EXTENSION adminpack; CREATE EXTENSION

Create New User and Database
For example, let us create a new user called “demo” with password “demo”, and database called “mydb”.sudo -u postgres createuser -D -A -P demo

sudo -u postgres createdb -O demo mydb

Delete Users and Databases
To delete the database, switch to postgres user: sudo -u postgres psql postgres
Enter command: $ drop database (database-name)

$ drop user (user-name)
