我不久前在Ubuntu 16.10上安装了Postgres 9.5,按照此处的说明进行操作。
我需要在独立模式下运行 Postgres 以获得数据库真空。我需要运行以下命令:
postgres --single -D /full/path/to/datadir postgres
但是postgres
命令不可用:
$ postgres
No command 'postgres' found, did you mean:
Command 'postgrey' from package 'postgrey' (universe)
postgres: command not found
它在postgres
用户路径中也不可用:
dbuser@pgserver:~$ sudo -i
root@pgserver:~# su postgres
postgres@pgserver:/root$ postgres
No command 'postgres' found, did you mean:
Command 'postgrey' from package 'postgrey' (universe)
postgres: command not found
此实用程序在哪里,或者我需要安装什么才能访问它?
postgres
命令(以及pg_ctl
和其他命令(在/usr/lib/postgresql/9.5/bin
中。
值得注意的是,它们必须由像postgres
这样的非特权用户运行。以下是我为解决我的问题所做的工作:
-
为邮政用户创建主目录:
$ sudo -i $ mkdir /home/postgres $ chown postgres:postgres /home/postgres $ usermod -d /home/postgres/ postgres
-
编辑路径:
$ su - postgres $ vim ~/.bash_profile
附加:
PATH=$PATH:/usr/lib/postgresql/9.5/bin export PATH
-
运行
su - postgres
以访问命令:$ postgres --single -D /full/path/to/datadir postgres PostgreSQL stand-alone backend 9.5.7 backend>