在conda环境中安装后无法启动PostgreSQL

时间:2019-03-24 17:12:17

标签: postgresql

我正在运行Ubuntu 18.04.2 LTS。我在conda install postgresql环境中输入conda安装了postgresql。现在我仅在我的环境中安装了postgresql 11.2。

我的理解是postgres服务器应该自动启动,因此当我运行sudo -u postgres psql时,我将以postgres用户身份登录。相反,当我运行此命令时,我得到:

sudo: unknown user: postgres
sudo: unable to initialize policy plugin

然后我只运行了psql,这又产生了另一个错误:

psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

最后,检查我正在运行的进程时,postgres没有任何内容,因此我认为服务器根本没有运行。

现在,我可以找到解决方法并最终启动服务器,但是我不明白如何在这种情况下工作。我的问题是:

  1. 为什么服务器不能自己启动?
  2. 在安装postgresql时,首先将其安装在环境中是好的,还是最好使用sudo apt install postgresql并将其全局安装在服务器上?
  3. 如何以最佳方式解决这种情况?

谢谢!

2 个答案:

答案 0 :(得分:1)

  
      
  1. 为什么服务器不能自己启动?
  2.   

<div *ngIf="config.editing"> <input #first type="text" placeholder="xxx xx aaaa..." [(ngModel)]="config.first"> <input #second type="text" placeholder="xxx aaaa..." [(ngModel)]="config.second"> <input #amount type="text" (keyup)="onKeyUp()" placeholder="xxx" [(ngModel)]="config.rendition"> <input (click)="onSave()" type="button" value="save"> </div> 不会将PostgreSQL安装为系统服务。它只是安装必要的软件。

conda是一个跨平台的程序包管理器,即它为python程序包提供了一种简单的方法来自动安装postgresql作为对Linux,MacOS和Windows的依赖(这对开发人员非常有用)。 但是,在撰写本文时,它还没有将已安装的二进制文件集成到操作系统的服务体系结构中(这将更多地取决于操作系统的细节)。

  
      
  1. 在安装postgresql时,首先将其安装在环境中是好的,还是最好使用sudo apt install postgresql并将其安装在全局服务器上?
  2.   

如果您想要方便,那么conda最适合您-这是为您的Ubuntu版本量身定制的,您无需关心启动/停止服务器的情况。

您不太可能需要并排安装多个postgres。

  
      
  1. 如何以最佳方式解决这种情况?
  2.   

sudo apt install postgresql

答案 1 :(得分:1)

jsperf是答案:

在本地创建基础数据库:

initdb -D mylocal_db

现在启动postgres的服务器方式/实例:

pg_ctl -D mylocal_db -l logfile start
相关问题