首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Ubuntu18.04上首次安装PostgreSQL 14.1有问题

在Ubuntu18.04上首次安装PostgreSQL 14.1有问题
EN

Stack Overflow用户
提问于 2021-12-15 01:24:01
回答 1查看 374关注 0票数 0

我第一次尝试安装PostgreSQL 14时遇到了一些麻烦。

如果有人以我即将提出的方式提出这一问题,我想事先表示歉意,但我认为没有。如果是的话,请指导我到适当的地点!

我在这件事上做了相当多的谷歌搜索,我发现的所有信息似乎都很零碎,或者我最终遵循了超链接的意大利面轨迹(一个la-do-this-and-follow-this-other-link-with-more-information-than-you-need-to-understand-this-other-required-portion). )就我个人而言,我不想跳到网络上的50个不同的地方,试图想出一个零敲碎打的解决方案,我相信相信可以工作,但后来却被证明是错误的。我想知道该做什么和为什么它工作。我试着阅读文档,并放弃了它,因为在我看来,它似乎假设服务器已经由数据库管理员设置。

与其直截了当地阐述我的问题(因为我似乎遇到了比我想要的麻烦更多的麻烦),我认为,通过第一次在安装PostgreSQL之后说明我的期望值,间接地表达我的问题会更容易。

首先,我将提到我正在运行Ubuntu18.04.6LTS,并使用以下命令安装PostgreSQL 14.1

代码语言:javascript
复制
sudo apt install postgresql-14

在继续之前,我想预先添加一个附带说明,即i不希望为另一种操作系统或安装方法提供建议。我只想从这一点开始,以一种常识的方式“启动和运行”。

接下来,我知道前面的命令创建了一个名为postgres的*nix用户。

从这里,我现在可以间接地陈述我的问题,使用一个大纲,我的目标和期望是什么,立即安装软件后,通过该命令。

  • After通过apt安装PostgreSQL,这是我预期的目标:PostgreSQL
  • I希望 any 客户机能够从从客户端到服务器的路由存在的任何计算机连接到数据库服务器。为了简单起见,为了简单起见,为了实现这些既定的目标或某种逻辑局域网(如广域网或VPN).

)

代码语言:javascript
复制
- If I change the PostgreSQL password of the **postgres** user, I expect that any client logging into the database  server via the **postgres** user will require the password. 
    - This means if I want to change the password to **some\_password** via `\password postgres` or `ALTER USER postgres WITH PASSWORD 'some_password';` _(I am assuming this is how you change the login password of a PostgreSQL user)_, then... 
        - I expect running `psql [-h host] -U postgres -W` from **any** host... 
            - That when I am prompted to enter the password...  
            - I can **only** log in by entering the exact password of **some\_password**.
            - Entering any other arbitrary text for the password should not allow me to log in. 
            - I am adding this as a requirement because previous install attempts have shown me that this is NOT the case.
代码语言:javascript
复制
    - I expect to be able to create a PostgreSQL user account other than **postgres** (e.g. **db\_user**) _with_ a password and have it be subject to the same requirements as the **postgres** user. 
        - i.e. once the new account is given permission to log in, the same common-sense login requirements to log in **must** be imposed, i.e. you can't get in if you don't have the correct username/password combination. 

如果能够以这样一种方式来解释实现上述目标的过程,那么我将非常感激。

请放心,我的知识与刚刚完成大学一年级的CS本科生一样,他们也了解Linux文件系统和基本的计算机网络。我只想让尽可能多的人都能找到答案,因为我确信,我不是唯一一个为安装PostgreSQL而苦苦挣扎的人,尽管拥有一个超级用户的计算机素养水平。

EN

回答 1

Stack Overflow用户

发布于 2021-12-15 02:48:11

  1. sudo apt安装postgresql

  1. sudo -u postgres psql

代码语言:javascript
复制
- Set a password for this user with \password or the other method you mention

/etc/postgresql/10/main/pg_hba.conf

  1. sudo vi

代码语言:javascript
复制
- Make the only uncommented nonblank line in this file be `host all all all md5`

/etc/postgresql/10/main/postgresql.conf

  1. sudo vi

代码语言:javascript
复制
- uncomment listen\_addresses line and set it to '\*'

  1. sudo服务postgresql重新启动

创建新用户时,还应该创建一个与用户拼写相同的新数据库。否则,在尝试使用psql -U (如psql -U newname -d postgres -h[hhh] )登录时,需要指定数据库名。如果您实际运行的是14而不是10,那么您将需要相应地更改您需要编辑的配置文件的路径。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70357457

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档