About
RSS

Bit Focus


Configurations Trouble Shooting for Postgres 9 on CentOS 7

0. Change the Data Directory

For some reason the -D or --pgdata arguments passed to initdb command doesn't work. The solution is modifying /etc/init.d/postgres-X.Y, changing this line

PGDATA=path

And run initdb again (of course -D or --pgdata is not necessary any more).

1. Access Control

The network access is set as ident after installation. If you want to use username/password to login the database, which is much easier (but may have some security problems as you need to keep the password carefully), you need to change ... well the file name is not explicitly documented. You are supposed to execute the following command to find it out.

show hba_file

Postgres will give you the path where the configure file locates (usually a pg_hba.conf file). Open that file, modifying this line

# host  all    all     127.0.0.1/32   ident
# change it to
host    all    all     127.0.0.1/32   password

Clarification: you must use the postgres user (the UNIX user) to login your localhost Postgres server to execute show hba_file, as all other users are required to provide the ident in this case.

You might have noticed that the IP address is 127.0.0.1 in that file. This address means all connections from 127.0.0.1 (the localhost) are required to provide the username/password. If you have several hosts in your internal network, you may need change that address into this (assume your internal network has addresses in the pattern of 192.168.*.*)

host    all    all     192.168.0.0/16   password

Permanent Link: /p/3 Load full text

Post tags:

 Postgres
 CentOS


. Back to Bit Focus
NijiPress - Copyright (C) Neuron Teckid @ Bit Focus
About this site