0. Change the Data Directory
For some reason the
--pgdata arguments passed to
initdb command doesn't work. The solution is modifying
/etc/init.d/postgres-X.Y, changing this line
initdb again (of course
--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.
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
host all all 192.168.0.0/16 password