How to restore PostgreSQL dump file into Postgres databases?

后端 未结 7 780
小鲜肉
小鲜肉 2020-12-04 14:05

I have a dump file with a .SQL extension (in fact it is a plain-text SQL file). I want to restore it into my created databases. I am using pgAdmin III, and when

相关标签:
7条回答
  • 2020-12-04 15:05

    1.open the terminal.

    2.backup your database with following command

    your postgres bin - /opt/PostgreSQL/9.1/bin/

    your source database server - 192.168.1.111

    your backup file location and name - /home/dinesh/db/mydb.backup

    your source db name - mydatabase

    /opt/PostgreSQL/9.1/bin/pg_dump --host '192.168.1.111' --port 5432 --username "postgres" --no-password --format custom --blobs --file "/home/dinesh/db/mydb.backup" "mydatabase"

    3.restore mydb.backup file into destination.

    your destination server - localhost

    your destination database name - mydatabase

    create database for restore the backup.

    /opt/PostgreSQL/9.1/bin/psql -h 'localhost' -p 5432 -U postgres -c "CREATE DATABASE mydatabase"

    restore the backup.

    /opt/PostgreSQL/9.1/bin/pg_restore --host 'localhost' --port 5432 --username "postgres" --dbname "mydatabase" --no-password --clean "/home/dinesh/db/mydb.backup"

    0 讨论(0)
提交回复
热议问题