-
Dump remote database:
$ pg_dump -U uni -h 104.196.175.120 postgres -n uni > ~/Desktop/backup.sql
-
Stop postgre
$ sudo -u postgres bash -c 'killall postgres'
-
Set environment variables:
a. Create environment file:
$ touch ~/.bashrc $ vim ~/.bashrc
b. Edit content:
# this goes into ~/.bashrc export PGDATA=/home/<YOUR USERNAME>/pgdata export PGPORT=5432 # this makes sure the installed posgresql tools are available in the shell export PATH=/usr/lib/postgresql/9.3/bin:$PATH
c. Reload bashrc
$ source ~/.bashrc
-
Allocate the files that PostgreSQL will use into the $PGDATA directory:
$ initdb -D $PGDATA
-
Edit configuration file:
$ vim $PGDATA/postgresql.conf
At around line 59, uncomment the two options:
listen_addresses = 'localhost' port = 5432
-
Start | restart | stop DBMS:
$ pg_ctl start | restart | stop
-
Create a database:
$ createdb test
-
Import dump file into database:
$ psql test < backup.sql
-
In python server, set
DATABASEURI = 'postgresql:///test'