Index

How to run PostgreSQL as a non-privileged user

The quick and dirty guide to setup a postgres database without root access.

Create a directory where your data will live:

$ postgres_dir="$HOME/postgres"
$ mkdir -p "$postgres_dir"
$ initdb -D "$postgres_dir"
[lots of output...]

Then run postgres:

postgres -D "$postgres_dir"

Create and database for yourself:

$ createdb $(whoami)
$ psql
user=#

To stop the server type Ctrl-C, or you can use pg_ctl if postgres runs in the background:

pg_ctl stop -D "$postgres_dir"