postgresql - 如何将默认的 postgres super 用户重命名为 "root"?

标签 postgresql gentoo

我目前使用 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/

相关文章:

sql - 使用 postgres 将 Excel 日期格式转换为常规日期

ruby-on-rails - 通过在数据库中的 View 上运行 sql 对结果进行分页

php - `mcrypt_create_iv` 停止,但仅通过 Apache

linux - 如何在Linux系统中找到可以安装哪个合适版本的glibc

postgresql - 使用 docker swarm 模式时如何将数据保存在卷上?

java - 通过 SetIcon 从 postgres 中的 bytea 数据类型更新 JLabel

sql - Union Join on postgresql with timestamp column

linux - 在 Gentoo Linux 发行版上构建和安装 NodeJs

c++ - boost cpu_timer入门,错误: ‘boost::timer::cpu_timer’ has not been declared

c - 使用可用的堆栈保护器 SSP 搜索 GCC 版本