• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

没办法使用其他用户名从pg_dump恢复photoshopql数据库

用户头像
it1352
帮助1

问题说明

我需要从computer1中以postgres用户名1转储一个postgres数据库,然后在具有postgres用户名2的computer2上恢复它.我一直遇到似乎备份文件要使用username1的错误:

I need to dump a postgres database from computer1 with postgres username1 and then restore it on computer2 with postgres username2. I keep running into the error that looks like the backup file wants to use username1:

当我在computer2上运行它时:

When I run this on computer2:

psql dbname < backupname.pgsql

我收到此错误:

ERROR:  role "username1" does not exist

我尝试过:

// Dumping from computer1:

pg_dump dbname > backupname.sql
pg_dump dbname > backupname.pgsql
pg_dump -U username1 dbname -N topology -T spacial_ref_sys > backupname.pgsql


// Restoring on computer2:

psql dbname < backupname.pgsql

是否需要对转储或还原进行修改以克服此问题?

Is it the dumping or the restoring that needs to be modified to get past this?

正确答案

#1

问题出在转储上.通过此帖子的见识,我能够解决此问题使用:

The problem is with the dumping. With insight from this post I was able to resolve this using:

// On Computer1

pg_dump dbname -O -x > backupname.sql


// On Computer2

psql dbname < backupname.sql

pg_dump一起使用的选项标志是:

The option flags used with pg_dump are:

-O   <-- No owner
         Do not output commands to set ownership of objects to match the original database

-x   <-- No privileges
         Prevent dumping of access privileges (grant/revoke commands)

有关更多信息,请参见 PostgreSQL文档pg_dump 选项标志.

See the PostgreSQL docs for pg_dump for more info on the option flags.

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhcfiaff
系列文章
更多 icon
同类精品
更多 icon
继续加载