PostgreSQL

# install package
apt install postgresql

# connect
psql -h <hostname> -p 5432 -U <username> -d <dbname> -W

\l  # list databases
\c <dbname>  # connect to a database
\dt  # list tables

# dump
pg_dump -h <hostname> -p 5432 -U postgre -W -F t <dbname> > ./<dumpname>.tar

# restore
pg_restore -d <dbname> ./<dumpname>.tar -c -U <username> -h <hostname> -p 5432
  • postgresql.txt
  • Last modified: 2019/10/14 10:32
  • by jdx