How to change Default Port used by PostgreSQL 9.5 on CentOS 7?

Does someone have an idea about how to change default port for PostgreSQL 9.5, I did the same on previous versions and I just modify the following files:

/var/lib/pgsql/9.5/data/postgresql.conf

listen_addresses = '*'

port = 4000

/etc/phpPgAdmin/config.inc.php

$conf['servers'][0]['host'] = 'localhost';

$conf['servers'][0]['port'] = 4000;

I am using phpPgAdmin to check out the Database from the web, it works with default port, but it doesn't work when not using the default port, also in the terminal i get this error after restarting postgresql service:

[root@cos7psql01 system]# su - postgres
Last login: Sun Jan 17 12:38:27 CST 2016 on pts/0
-bash-4.2$ psql
psql: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

*Port set to 4000 is just an example.

Thanks in advance!

0
задан 17 January 2016 в 21:15
1 ответ

Ваша конфигурация выглядит нормально, но то, как вы пытаетесь подключиться к службе, - нет. Если вы не укажете настраиваемый порт, он попытается подключиться через порт по умолчанию.

Попробуйте использовать флаг -p , чтобы указать, что вы хотите подключиться через определенный порт:

psql -p 4000
2
ответ дан 4 December 2019 в 13:44

Теги

Похожие вопросы