sudo apt-get install build-essential libreadline-dev
tar -xvjf postgresql-9.3.5.tar.bz2
sudo mkdir /usr/local/pg
cd postgresql-9.3.5
./configure --prefix=/usr/local/pg
make -j
-j:开启多核编译
如果有:All of PostgreSQL successfully made. Ready to install. 表示编译成功
sudo make install
如果出现:PostgreSQL installation complete. 表示安装成功
sudo useradd -s /bin/bash -d /home/postgres postgres
sudo mkdir /usr/local/pg/data -p
sudo chown postgres:postgres /usr/local/pg/ -R
su - postgres
/usr/local/pg/bin/initdb -D /usr/local/pg/data
/usr/local/pg/bin/postgres -D /usr/local/pg/data >logfile 2>&1 &
或者
/usr/local/pg/bin/pg_ctl -D /usr/local/pg/data -l logfile start
/usr/local/pg/bin/createdb test
/usr/local/pg/bin/psql test