我目前使用 psql -U postgres
登录到 PostgreSQL。如何将 postgres
用户重命名为 root
?
如果我已经以 postgres
身份登录,那么尝试 ALTER USER postgres RENAME TO root
会提示 ERROR: session user cannot be renamed
。
是否可以在不登录为 postgres
用户的情况下重命名用户?我认为我没有任何其他 super 用户,因为这是 PostgreSQL 的全新安装。
顺便说一句,我在 Amazon EC2 上运行 Gentoo。
最佳答案
您应该能够通过以 postgres 用户身份登录并(在 shell 中)键入来创建一个名为 root 的新 postgres super 用户;
createuser --superuser root
psql> create database root owner root
之后,当以 root 身份登录时,您应该能够使用 postgres 用户执行您想要的操作。
关于postgresql - 如何将默认的 postgres super 用户重命名为 "root"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9607447/