PostgreSQL源码下载
源码可以利用git下载,git clone git://git.postgresql.org/git/postgresql.git
官方ftp下载,https://ftp.postgresql.org/pub/source/v9.5rc1/postgresql-9.5rc1.tar.bz2
版本为目前的最新版本,9.5rc1.
配置文件
进入源码根目录,cd postgresql-9.5rc1
生成makefile文件,./configure
开启debug,./configure --enable-debug
查看configure配置,./configure -f
编译安装
sudo make&make install
配置环境变量
编辑环境变量文件,vim ~/.bashrc
export PATH=/usr/local/pgsql/bin:$PATH
新建数据目录,sudo mkdir /pgdata
变更数据目录权限,sudo chown -R postgresql /pgdata
配置PGDATA目录,PGDATA=/pgdata
export PGDATA
初始化数据库
initdb
默认使用PGDATA目录
启动数据库服务
pg_ctl start
查看服务启动情况,ps -ef|grep postgres
postgres 1176 1 0 22:37 pts/2 00:00:00 /usr/local/pgsql/bin/postgres
postgres 1179 1176 0 22:37 ? 00:00:00 postgres: checkpointer process
postgres 1181 1176 0 22:37 ? 00:00:00 postgres: writer process
postgres 1183 1176 0 22:37 ? 00:00:00 postgres: wal writer process
postgres 1184 1176 0 22:37 ? 00:00:00 postgres: autovacuum launcher process
postgres 1185 1176 0 22:37 ? 00:00:00 postgres: stats collector process
以上是启动postgresql以后的各个服务进程。
简单测试
连接数据库,psql postgres
postgres是默认数据库,默认端口为5432
创建一个表,
postgres=# create table t1(f1 int);
CREATE TABLE
创建成功
开启时间函数,
postgres=# \timing on
Timing is on.
insert一条记录
postgres=# insert into t1 values(1);
INSERT 0 1
Time: 3.072 ms
完
转载于:https://my.oschina.net/u/2604075/blog/597183