Restoring from Postgres sql file

百般思念 提交于 2019-12-02 16:46:19

问题


I have a backup from PostgresSQL database created this way:

/usr/bin/pg_dump --no-owner --no-acl > dump.sql

When I try to restore on a different machine:

psql db < dump.sql it trows many errors: invalid command \N

When I try to use pg_restore:

pg_restore dump.sql -d db

Different error: pg_restore: [archiver] input file appears to be a text format dump. Please use psql.

According to documentation this should be a non issue.

Any way to tell psql that \N character is a null value?


回答1:


Oh hi me, it's me

Make sure:

  • Database exists
  • Importing user has permissions
  • Get the first error before \N ones flood in
  • psql -d database -f backup.sql -U user should do the trick for importing

Also eat healthy and get good rest. k bye



来源:https://stackoverflow.com/questions/53292514/restoring-from-postgres-sql-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!