【发布时间】:2017-10-12 07:52:20
【问题描述】:
全新安装 CentOS 7 需要全新安装 PostgreSQL,并使用新用户和新角色。我正在关注the steps described in this tutorial 来实现这个目标。但是,当我键入 createuser -interactive 时,终端没有提供教程承诺的交互式菜单。相反,我得到以下空白提示:
[this_centos_user@localhost ~]$ sudo -i -u postgres
[sudo] password for this_centos_user:
-bash-4.2$ createuser –interactive
-bash-4.2$
需要输入哪些具体命令才能让交互式createuser 界面出现并让我提供用户名、密码等?
具体情况:
1.) 首先,我使用以下命令安装了 postgresql-server 包和“contrib”包:
sudo yum install postgresql-server postgresql-contrib
2.) 接下来,我创建了一个新的 PostgreSQL 数据库集群:
sudo postgresql-setup initdb
3.) 然后我通过键入sudo vi /var/lib/pgsql/data/pg_hba.conf 并更改以下行以包括 md5 而不是 ident 来设置密码身份验证编辑 PostgreSQL 的基于主机的身份验证 (HBA) 配置:
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
4.) 保存并退出vi 后,我使用以下命令启动并启用了 PostgreSQL:
sudo systemctl start postgresql
sudo systemctl enable postgresql
5.) 接下来,我使用上面创建的postgres 帐户登录PostgreSQL,并尝试使用上面OP 顶部的代码创建用户,如下所示:
[this_centos_user@localhost ~]$ sudo -i -u postgres
[sudo] password for this_centos_user:
-bash-4.2$ createuser –interactive
-bash-4.2$
那么我该如何创建这个用户呢?
【问题讨论】:
标签: linux postgresql centos centos7 rhel