我用
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
当前回答
如果您恢复。sql文件。 在pgAdmin中创建一个新数据库。 进入终端,浏览.sql文件所在的文件夹/目录。然后在终端中写入以下命令。
让: 超自然用户后
Examaple:
sudo -u postgres psql newDb < restoreDb.sql
其他回答
如果你用这种方式备份,我想这会更容易导入数据库。
pg_dump -h(远端数据库地址)-a——column-inserts -U postgres(数据库名)>(文件名).sql
对于进口,
psql -f(文件名).sql ——host(远程数据库地址) ——端口5432 ——用户名postgres ——password(你的密码) ——dbname(你要导入的数据库)
来自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
psql -U <username> -d <database-name> -h <host-name> -f <backup.sql> . p
上面的答案对我没用,下面这个有用:
PSQL 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