Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql Ubuntu中独立模式的Postgres可执行文件_Postgresql - Fatal编程技术网

Postgresql Ubuntu中独立模式的Postgres可执行文件

Postgresql Ubuntu中独立模式的Postgres可执行文件,postgresql,Postgresql,不久前,我按照说明在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' (un

不久前,我按照说明在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

此实用程序在哪里,或者需要安装什么才能访问它?

命令(以及
pg_ctl
和其他命令)位于
/usr/lib/postgresql/9.5/bin

值得注意的是,它们必须由非特权用户运行,如
postgres
。以下是我为解决我的问题所做的:

  • 为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>