Monday 28 November 2011

How to Postgres Create Datase, User Commands

These are some basic steps to follow for newbie how to use postgres database!
1:- Create database:

First install the postgresql on your server or locally.
Then follow the below steps to create the Database!
by default there is no database in postgres so you have to user the default user.

You need to login as database super user under postgresql server. Again the simplest way to connect as the postgres user is to change to the postgres unix user on the database server using su command as follows:
su - postgress

insert the command
#psql template1

tamplat1#

2:Add user shahmeer
template1# CREATE USER shahmeer WITH PASSWORD 'helloE^$(0~E';

3: Create Database firstdb:
template1=# CREATE DATABASE firstdb;

Now grant all privileges on database

template1=# GRANT ALL PRIVIGES ON DATABASE firstdb to shahmeer;

Type \q to quit:
template1# \q 
/////////////////////////////////////////////////////////////////////////////

Test user shahmeer login:

#psql -U shahmeer -d firstdb

firstdb> \l;

will show all the databases in postgresql:

........................................................................................

No comments:

Post a Comment