Installing PostgreSQL without Root

 

Introduction

The only way to install Postgres without root privileges, in home directory, is to compile it from sources. That’s not very difficult.

Usage

See below for installation
psql --version

 

Installation

mkdir -p /export/home/YOURSNUMBER/sw/PostgresSQL/src
cd /export/home/YOURSNUMBER/sw/PostgresSQL/src
wget https://github.com/postgres/postgres/archive/master.zip

module load gcc/6.3.0
module load library/zlib/1.2.11
module load python/3.6.1

unzip master.zip
cd /export/home/YOURSNUMBER/sw/PostgresSQL/src/postgres-master

./configure --prefix=/export/home/YOURSNUMBER/sw/PostgresSQL/ --with-python PYTHON=/sw/python/3.6.1/bin/python  2>&1 | tee ConfigureLog.txt
make -j 4 2>&1 | tee MakeLog.txt
make install  2>&1 | tee MakeInstallLog.txt

 

Create database

~/sw/PostgresSQL/bin/initdb -D ~/sw/PostgresSQL/data/

Start database server:
~/sw/PostgresSQL/bin/postgres -D ~/sw/PostgresSQL/data/
OR:
~/sw/PostgresSQL/bin/pg_ctl -D ~/sw/PostgresSQL/data/ -l logfile start

~/sw/PostgresSQL/bin/psql --version
~/sw/PostgresSQL/bin/psql -U YOURSNUMBER postgres
postgres=# select version();
postgres=# show data_directory ;



 

Reference

 

  1. http://blog.endpoint.com/2013/06/installing-postgresql-without-root.html