没办法使用其他用户名从pg_dump恢复photoshopql数据库
问题说明
我需要从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?
正确答案
问题出在转储上.通过此帖子的见识,我能够解决此问题使用:
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
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20 -
希伯来语的空格句子标记化错误
it1352 06-22