Activities

November 2009
M T W T F S S
« Oct   Dec »
 1
2345678
9101112131415
16171819202122
23242526272829
30  

PosgreSQL administration

Here are some posgresql administrative commands,

1, Connecting a database

#psql  -h localhost -p 5432 postgres "admin"

which connect the user ‘posgres’ with ‘admin’ as password.
2. Create a user from psql console

postgres=# CREATE USER luntbuild;

3. Change the password of the user

 postgres=# ALTER USER luntbuild PASSWORD 'luntbuild

‘;
4, Create database which owned by a user

postgres=# CREATE DATABASE luntbuild WITH OWNER luntbuild;

5. Importing script to a database

postgres=# source luntbuild/db/postgresql/luntbuild.sql;

6. How to backup a postgresql database
a, Backing up only database

#pg_dump -a -d database  -f filename.sql


b. Dumping only database schema
#pg_dump -s -d database -f filename.sql
c. Backing up a database

#pg_dump  -d database -f  filename.sql

7. Taking full all databases:

$ pg_dumpall > filename.sql

8.How to restore the database,

 $ psql -d database  -f filename.sql  -UUser

-Njoy

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>