postgresql 用户“postgres”错误没有密码条目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27211158/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 05:50:27  来源:igfitidea点击:

No passwd entry for user 'postgres' error

postgresqlubuntu

提问by zan

I'm trying to setup Postgres on Ubuntu 14.04 without success. After running

我正在尝试在 Ubuntu 14.04 上设置 Postgres,但没有成功。运行后

sudo apt-get install libpq-dev python-dev

须藤 apt-get 安装 libpq-dev python-dev

and

sudo apt-get install postgresql postgresql-contrib

sudo apt-get 安装 postgresql postgresql-contrib

I've managed to install the packages successfully. However upon executing sudo su - postgres, I'm receiving the following error:

我已经成功安装了这些软件包。但是,在执行sudo su - postgres 时,我收到以下错误:

No passwd entry for user 'postgres'

用户“postgres”没有密码条目

It seems like the installation did not create the user postgres as it is not in the /etc/passwd file. Reinstalling the package does not resolve the issue. How can I add the required postgres user?

安装似乎没有创建用户 postgres,因为它不在 /etc/passwd 文件中。重新安装软件包不能解决问题。如何添加所需的 postgres 用户?

回答by Craig Ringer

It sounds like you want the PostgreSQL server:

听起来你想要 PostgreSQL服务器

apt-get install postgresql-server

Also, you never need to use sudo su - postgres. Just:

此外,您永远不需要使用sudo su - postgres. 只是:

sudo -u postgres -i

to get an interactive shell, or

获取交互式外壳,或

sudo -u postgres psql

(or whatever) to run a command.

(或其他)运行命令。

回答by zan

I've solved the issue by purging and re-installing the packages, i.e.

我已经通过清除并重新安装软件包解决了这个问题,即

sudo apt-get --purge remove postgresql*

sudo apt-get install postgresql postgresql-contrib

sudo apt-get --purge 删除 postgresql*

sudo apt-get 安装 postgresql postgresql-contrib