? ? 今天在写入PostgreSQL的dapp_namemap表格时,报"psycopg2.errors.InsufficientPrivilege: permission denied for table"错误,如图(1)所示。
? ? 问题原因:当前用户hello对表格没有读写权限,如表格(1)所示。 ? ? 解决方法:使用超级用户,进入表格所在的数据库,然后对当前用户授予读写权限。 ? ? 详细如下:
? ? 使用超级用户postgres,登录指定的数据库(根据自己的情况按需指定),本案例的DB是hellodb,注意,不要登录默认的数据库PG,否则就缘木求鱼了。如果登录了默认的数据库,就是默认数据库PG对hello用户的授权,而不是hellodb数据库对hello用户的授权。
psql -U postgres -d hellodb 2 授予hello用户读写权限 grant usage on schema public to hello; grant all privileges on all tables in schema public to hello; grant all privileges on all sequences in schema public to hello; grant select,insert,update,delete on all tables in schema public to hello; grant all on schema public to hello;? ? 如图(2)所示:
图(2) 登录指定的数据库,并授权 3 查询权限? ? 使用命令,查询hello的权限
select * from information_schema.table_privileges where grantee='hello';? ? 效果如下:
图(3) 授权成功
1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,会注明原创字样,如未注明都非原创,如有侵权请联系删除!;3.作者投稿可能会经我们编辑修改或补充;4.本站不提供任何储存功能只提供收集或者投稿人的网盘链接。 |
标签: #Permission #denied #for #table问题