User Tools

Site Tools


postgressnippets

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
postgressnippets [2006/03/01 20:45] – created andipostgressnippets [2006/11/13 16:13] (current) – old revision restored andi
Line 1: Line 1:
 +====== Postgres Snippet ======
 +
 +I'm a MySQL user so remembering the Postgres stuff is hard ;-)
 +
 +===== Enable Network Access =====
 +
 +In ''/etc/postgresql/8.1/main/pg_hba.conf'' add:
 +
 +  host    all         all         192.168.1.0/24        md5
 +
 +In ''/etc/postgresql/8.1/main/postgresql.conf'' add:
 +
 +  listen_addresses = '*'
 +
 +Then restart postgres.
 +
 +===== Create new User and DB =====
 +
 +  $> sudo -u postgres createuser <user>
 +  $> sudo -u postgres createdb --owner <user> <database>
 +
 +===== Add password for user =====
 +
 +  $> sudo -u postgres psql
 +  ALTER USER <user> WITH PASSWORD '<password>';
 +
 +===== Database Backup =====
 +Useful to make a fresh database install on another machine.
 +
 +==== Do the backup ====
 +Create a backup of astj_dev_0 that we will call astj_dev_0.bak
 +  pg_dump -U postgres astj_dev_0 >/tmp/astj_dev_0.bak
 +
 +==== Create the database ====
 +Create a new database with username and desired encoding.
 + createdb --username=<oneusername> --encoding=latin1 <databasename>
 +
 +==== Do the restore ====
 +   psql --username=<username> -d <databasename> </tmp/astj_dev_0.bak