1.下载源码包: http://ftp.postgresql.org/pub/source/v9.2.4/postgresql-9.2.4.tar.bz2linux
2.安装依赖:apt-get install gcc make libreadline6 libreadline6-dev (提醒缺乏什么就安装什么,如提示缺乏,zlib库,请参照http://greenzb.blog.51cto.com/745896/1212817,安装)sql
3.开始编译:数据库
(1)解压源码包到 /home/linux/postgresql-9.2.3 ide
(2)./configure --prefix=/要安装postgresql到哪一个目录post
(3)sudo make(成功提示:All of PostgreSQL successfully made. Ready to install.)postgresql
(4)su(切换到root用户)server
(5)make install(成功提示:PostgreSQL installation complete.)blog
(6)adduser postgresget
(7)建立数据目录:mkdir /你安装postgresql的目录/data源码
(8)修改拥有者:chown postgres /你安装postgresql的目录/data
(9)切换到postgres用户:su - postgres
(10)初始化数据目录:/你安装postgresql的目录/bin/initdb -D /你安装postgresql的目录/data(成功提示:Success. You can now start the database server using:
/opt/postgresql-9.2/bin/postgres -D /opt/postgresql-9.2/data
or
/opt/postgresql-9.2/bin/pg_ctl -D /opt/postgresql-9.2/data -l logfile start)
(11)启动postgresql服务:/你安装postgresql的目录/bin/postgres -D /你安装postgresql的目录/data >logfile 2>&1 &
(12)建立数据库:/你安装postgresql的目录/bin/createdb test
(13)链接到数据库:/你安装postgresql的目录/bin/psql test
若是成功,你将会看到:(
psql (9.2.3) Type "help" for help.)