我用
pg_dump db_production > postgres_db.dump
然后使用scp将其复制到localhost。
现在当我导入我的本地db时,它给出了一个错误
pg_restore: [archiver] input file appears to be a text format dump. Please use psql.
使用命令行
pg_restore -d db_development postgres_db.dump
我用
pg_dump db_production > postgres_db.dump
然后使用scp将其复制到localhost。
现在当我导入我的本地db时,它给出了一个错误
pg_restore: [archiver] input file appears to be a text format dump. Please use psql.
使用命令行
pg_restore -d db_development postgres_db.dump
当前回答
这是解,
pg_restore -U username -p 5432 -h 10.10.10.1 -d database_name < dump_file . pg_restore -U username -p 5432
其他回答
来自pg_dump文档:
例子
将一个名为mydb的数据库转储到一个sql脚本文件:
$ pg_dump mydb > db.sql
要将这样的脚本重载到(新创建的)名为newdb的数据库中:
$ psql -d newdb -f db.sql
将数据库转储到自定义格式的归档文件中:
$ pg_dump -Fc mydb > db.dump
将数据库转储到目录格式的归档文件中:
$ pg_dump -Fd mydb -f dumpdir
将一个归档文件重新加载到一个名为newdb的(新创建的)数据库中:
$ pg_restore -d newdb db.dump
来自pg_restore文档:
例子
假设我们已经将一个名为mydb的数据库转储到一个自定义格式的转储文件中:
$ pg_dump -Fc mydb > db.dump
删除数据库并从转储中重新创建数据库:
$ dropdb mydb
$ pg_restore -C -d postgres db.dump
如果你用这种方式备份,我想这会更容易导入数据库。
pg_dump -h(远端数据库地址)-a——column-inserts -U postgres(数据库名)>(文件名).sql
对于进口,
psql -f(文件名).sql ——host(远程数据库地址) ——端口5432 ——用户名postgres ——password(你的密码) ——dbname(你要导入的数据库)
如果使用pg_dump和-Fp进行明文备份,则使用以下命令:
cat db.txt | psql dbname
将所有数据复制到名为dbname的数据库
这是解,
pg_restore -U username -p 5432 -h 10.10.10.1 -d database_name < dump_file . pg_restore -U username -p 5432
对我来说,当我试图从远程主机恢复我使用
psql -U username -p 5432 -h 10.10.10.1 -d database < db.dump
工作得很好。如果不是远程,只是下面的命令工作。
psql -d database < db.dump