首页 > 解决方案 > 如何运行“postgres”命令(单用户)

问题描述

我已经postgres安装在 ubuntu 机器上,我可以通过以下方式进入命令行:

$ sudo -u postgres psql
psql (10.15 (Ubuntu 10.15-0ubuntu0.18.04.1))
Type "help" for help.

postgres=#

我可以通过执行以下操作来启动/停止服务器:

$ sudo service postgresql
Usage: /etc/init.d/postgresql {start|stop|restart|reload|force-reload|status} [version ..]

这两个看起来都不错。但是,我想在单用户模式下运行 postgres 来做几个测试。在postgres页面上,它提供了一些示例,例如:

要启动单用户模式服务器,请使用类似的命令
postgres --single -D /usr/local/pgsql/data other-options my_database

但是,如果我使用“postgres”命令,我只会收到一条错误消息,说我没有该命令:

$ postgres

Command 'postgres' not found, did you mean:

为了进入单用户模式,我需要安装什么来运行“postgres”命令?

标签: postgresql

解决方案


它已经安装,只是不在您的 PATH 中,因为预计您不会手动使用它。

它可能在“/usr/lib/postgresql/10/bin/postgres”之类的地方,或者您可以使用locatefind找到它。


推荐阅读