Postgres 用户、角色和权限

Postgres users, roles and permissions

我最近移动了托管环境,不得不备份旧的 Postgres 数据库并将其复制到新服务器。

在新服务器上,我导入了数据库,现在我在访问网站时收到错误django.db.utils.ProgrammingError: permission denied for relation django_site

我相信这是因为表的所有者,如果我执行 \l 我可以看到所有者是正确的用户 userW2E

      Name      |  Owner   | Encoding |  Collate   |   Ctype    |   Access privileges
----------------+----------+----------+------------+------------+-----------------------
 hypersrvdjango | userW2E  | UTF8     | en_US.utf8 | en_US.utf8 |

但是如果我这样做 \dt

List of relations
 Schema |               Name               | Type  |  Owner

--------+----------------------------------+-------+----------
 public | account_registeremailaddress     | table | postgres

所以我在努力

ALTER TABLE account_registeremailaddress OWNER TO userW2E;

并得到错误

ERROR:  role "userw2e" does not exist

我是 postgres 的新手,有点不确定如何让用户拥有我的表 userw2e

有人能帮忙吗?

userW2E这里是标识符,大小写混合使用双引号:

ALTER TABLE account_registeremailaddress OWNER TO "userW2E";

https://www.postgresql.org/docs/current/static/tutorial-table.html

SQL is case insensitive about key words and identifiers, except when identifiers are double-quoted to preserve the case

强调我的

还有https://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS