Thursday, August 9, 2007

Add user account to postgreSQL database

step:1 Add user to unix/linux - debian system



First you have issue following command to add unix/linux user..

# adduser user

It will ask name, password and bla bla.........

You can change password by issuing command like this...

# passwd password

step:2 Becomming a super user...



# su - postgres

Then u can connect to the database..

# psql template1

or

# psql -d template1 -U postgres

step:3 Add user....



It creates user called "user" and password called "password"

template1=# CREATE USER user WITH PASSWORD 'password';


step:4 Add a database called testdb....



template1=# CREATE DATABASE testdb;

step:5 Grant privileges to that database...



template1=# GRANT ALL PRIVILEGES ON DATABASE testdb to user;

exit from psql..

template1=# \q


step:6 Try to connect database ....



Try to connect to the database "testdb" user "user"

# su - user
# psql -d testdb -U user

enjoy......

1 comment: