0

I have installed postgres 9.5 in my linux(16.04) machine.I have started service using below command.

sudo service postgresql start

This will start postgres service as a postgres user. But I want to run postgres a different user(myown user).

How can I do .Please help !!.

1 Answer 1

1

You have to recursively change the ownership of the database directory to the new user.

If the WAL directory or tablespaces are outside the data directory, you have to change their ownership too.

Then you will have to configure the startup script so that it starts PostgreSQL as the new user. Watch out: if you installed the startup script with an installation package, any changes to it will probably be lost after an update.

I recommend that you don't do all that and continue running PostgreSQL as postgres.

Sign up to request clarification or add additional context in comments.

9 Comments

Thanks Laurenz. I have one more question where this postgres user creation will happen/in which file. If I can change user there itself then problem is solved right !!.
That is done my the server installation package. I don't think you want to roll your own, right?
I want to change the data_directory path in file /etc/postgresql/10/main/postgresql.conf.. data_directory= 'my/own/path'.only me/my-user can access that path,other user(postgres) can't access that path.I want to start service with my user so that I can access that mounted path.
I don't understand.
I am installing postgres in a docker container .By default there is one data_directory path mentioned in /etc/postgresql/10/main/postgresql.conf. I wanted to change that path and point to new path on the mounted volume. which is out side the container .Only I/with my user can access that volume no ther can access.So I wanted to start postgres with my user instead postgres.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.