This post is about postgresql commands and other stuffs about it. It will updated when I update it.
)
Change PosgreSQL postgres user password
sudo -u postgres psql postgres postgres=# ALTER USER postgres WITH ENCRYPTED PASSWORD 'a'; ALTER ROLE postgres=# \q
Create a database with a user that have full rights on the database:
sudo -u postgres createuser -D -A -P myuser sudo -u postgres createdb -O myuser mydb
ALTER Role alexia SUPERUSER;
# Dump database “inventory” of user “alexandria” at host “10.2.145.90″ port “5432″
# -d = “INSERT” mode; -O = no owner
pg_dump -U alexandria -W -h 10.2.145.90 -p 5432 -d -O inventory > dump.sql
/usr/bin/pg_dump -i -h 192.168.1.2 -p 5432 -U alexia -F c -v -f “/home/ananda/ref_data/ref_airlines.backup” -t ref_airlines -n public central
/usr/bin/pg_restore -i -h 192.168.1.2 -p 5432 -U alexia -d inv -v “/home/ananda/ref_data/ref_airlines.backup”
RESTORE WITHOUT OWNER:
/usr/bin/pg_restore -i -h 192.168.1.2 -p 5432 -U alexia -d inv -O -v “/home/ananda/ref_data/ref_countries.backup”
BACKUP PLAIN:
/usr/bin/pg_dump -i -h 192.168.1.2 -p 5432 -U alexia -F p -O -v -f “/home/ananda/ref_data/ref_countries.backup” -t ref_countries -n public inv