Create PostgreSQL Database without root privilege
You can run PostgreSQL without root privileges by creating
a new instance (which PostgreSQL calls a "cluster").
note: You can't use wrapper tools like Ubuntu's pg_ctlcluster if you do
this.
You must use only PostgreSQL's own tools.
To create new PostgreSQL instance with the superuser equal to
your USERNAME, data directory in $HOME/my_postgres, and
md5 auth enabled by default, use:
"initdb -D $HOME/my_postgres -A md5 -U $USER -W"
note: you will be prompted for a password for your database, this
should not be your cims password. Just make one up.
Now edit $HOME/my_postgres/postgresql.conf
1.set the port to some high number port over 10000
port = 12345 # (change requires restart)
2. since you wont have permission to write to /var/run/postgresql, change
unix_socket_directories to something like:
unix_socket_directories = '/home/your_username/my_postgres/run, /tmp'
note: you must create the run directory: mkdir $HOME/my_postgres/run
Now start your server ...
pg_ctl -D $HOME/my_postgres -l $HOME/my_postgres/logfile start
Next, create your database:
createdb -p 12345 -h $HOME/my_postgres/run
Now to connect to database ...
psql -p 12345 -h $HOME/my_postgres/run/
try
postgres=# select version();
postgres=# show data_directory ;
to exit ...
\q
To stop your database server
pg_ctl -D $HOME/my_postgres -w stop