Cod*_*Med 2 linux postgresql centos rhel centos7
CentOS 7 的全新安装需要全新安装 PostgreSQL,并具有新用户和新角色。我正在按照本教程中描述的步骤来实现此目标。但是,当我键入 时,终端没有提供教程承诺的交互式菜单createuser -interactive。相反,我收到以下空白提示:
[this_centos_user@localhost ~]$ sudo -i -u postgres\n[sudo] password for this_centos_user:\n-bash-4.2$ createuser \xe2\x80\x93interactive\n-bash-4.2$\nRun Code Online (Sandbox Code Playgroud)\n\n需要输入哪些具体命令才能createuser出现交互界面并让我输入用户名、密码等?
1.) 首先,我使用以下命令安装了 postgresql-server 软件包和“contrib”软件包:
\n sudo yum install postgresql-server postgresql-contrib
2.) 接下来,我创建了一个新的 PostgreSQL 数据库集群:
\n sudo postgresql-setup initdb
sudo vi /var/lib/pgsql/data/pg_hba.conf3.) 然后,我通过键入并更改以下行以包含 md5 而不是 ident 来 设置密码身份验证,编辑 PostgreSQL 基于主机的身份验证 (HBA) 配置:
host all all 127.0.0.1/32 md5\nhost all all ::1/128 md5 \nRun Code Online (Sandbox Code Playgroud)\n\n4.) 保存并退出后vi,我使用以下命令启动并启用了 PostgreSQL:
sudo systemctl start postgresql\nsudo systemctl enable postgresql\nRun Code Online (Sandbox Code Playgroud)\n\n5.) 接下来,我使用上面创建的帐户登录 PostgreSQL postgres,并尝试使用上面 OP 顶部的代码创建用户,如下所示:
[this_centos_user@localhost ~]$ sudo -i -u postgres\n[sudo] password for this_centos_user:\n-bash-4.2$ createuser \xe2\x80\x93interactive\n-bash-4.2$\nRun Code Online (Sandbox Code Playgroud)\n\n那么如何创建这个用户呢?
\n不是问题的直接答案,但相关:
如果您像我一样,在 psql 中输入过内容createuser --interactive,并且想知道为什么刚刚从 转到postgres=#,postgres-#那么您就误解了这些说明。使用 退出 psql Ctrl+C,然后以 postgres 用户身份从 shell\q运行。createuser --interactive