Postgresql – How to install PostgreSQL to run under a different system user than “postgres”

postgresql

I'm installing PostgreSQL on RedHat Linux using rpm installers and I'm trying to get the application to be owned and run by a system user other than "postgres", for example "dbuser5". It seems I could change the permissions on the postgres application and database files after the install, but then the /etc/init.d/postgresql script will still have references to the postgres system user. Since there may be other files that reference this default system user, I'm hoping there's some better way to do this.

Preferably, I'd like to configure this during the install, but if I have to do it after the fact, that should work as well.

Best Answer

Stop the database server, change the ownership on the Postgres data directory, update your startup scripts to reference the correct user, and start the database server again.
Document your changes so someone expecting Postgres to be running as a traditional Postgres user account won't be unpleasantly surprised.

If you are using RedHat's packaged Postgres installation (installed from yum/RPMs) you will need to be aware of this change and make sure to check the startup script when you upgrade to ensure it hasn't been overwritten.

Related Topic