First of all I am new to PostgreSQL coming from MySQL. I have just installed PostgreSQL from the Fedora repositories and created the postgres user as per the fedora wiki pages, by su-ing into the postgres user and creating its role using the psql shell.
# su - postgres
$ psql
> \password
Then I created a test script that is served through nginx that will create a test DB and populate it. I'm trying to log in from the script by using the postgres user and its password via peer authentication, with the following pdo dsn:
new PDO('pgsql:user=postgres password=**********');
However, after struggling with SELinux, the connection fails saying that the peer authentication failed, so I looked into the postgresql logs and found that:
The delivered username (postgres) and the athenticated username (apache) do not match.
So I can deduce that the user that owns the process that's trying to access the db is the user that's being authenticated, so I assume I have to create the corresponding role for the apache user in the db. But why does it do this? Is it some sort of security measure? Is there a way to use the postgres role or am I bound to the apache role?