暂无图片
pg_restore异机恢复
我来答
分享
ss
2024-11-05
pg_restore异机恢复

源库:psql (PostgreSQL) 9.4.26 

目标库:psql (PostgreSQL) 9.4.24

将原库testdb下tmp schema导入到目标库tdb下tmp schema,

pg_dump -d testdb -n tmp -t tmp.test1 -t tmp.test2 -Fd -j2 -f tmpbak1104
pg_restore -d tdb -n tmp -O tmpbak1104 -j2

导人时报错:

pg_restore: [archiver (db)] pg_restore: [archiver (db)] Error from TOC entry 122280; 0 0 ACL TABLE bi_dm_asset_mid_cust_month_his analyst
Error from TOC entry 122281; 0 0 ACL TABLE bi_dm_fund_stock analyst
pg_restore: [archiver (db)] pg_restore: [archiver (db)] could not execute query: ERROR: role "analyst" does not exist
Command was: REVOKE ALL ON TABLE tmp.bi_dm_asset_mid_cust_month_his FROM PUBLIC;
REVOKE ALL ON TABLE tmp.bi_dm_asset_mid_cust_month_his F...
could not execute query: ERROR: role "analyst" does not exist
Command was: REVOKE ALL ON TABLE tmp.bi_dm_fund_stock FROM PUBLIC;
REVOKE ALL ON TABLE tmp.bi_dm_fund_stock FROM analyst;
GRANT ALL ON TA...


postgresql 数据库在导入时,怎么忽略类似授权的错误,还是说必须要把对应的role全部建好?

我来答
添加附件
收藏
分享
问题补充
1条回答
默认
最新
寻寻觅觅

1、目标库创建角色,跟源库保持一致

2、导入时,忽略权限设置

pg_restore -d tdb -n tmp --no-owner --no-acl -j2 tmpbak1104

--no-owner:忽略所有者信息
--no-acl:忽略访问控制列表(ACL)信息

3、修改导出的文件,就是保留权限设置,但不想创建角色,可以加上 --no-acl 参数

pg_dump -d testdb -n tmp -t tmp.test1 -t tmp.test2 -Fd -j2 --no-acl -f tmpbak1104


目标库不想创建角色可以试试2、3

暂无图片 评论
暂无图片 有用 3
打赏 0
ss
题主
2024-11-08
-O参数已经加了,但是没看到有no-acl的参数,你是什么版本
回答交流
Markdown


请输入正文
提交
问题信息
请登录之后查看
邀请回答
暂无人订阅该标签,敬请期待~~
暂无图片墨值悬赏