PostgreSQL源码安装

  1.  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.

  2. 配置文件

    进入源码根目录,cd postgresql-9.5rc1

    生成makefile文件,./configure

    开启debug,./configure --enable-debug

    查看configure配置,./configure -f

  3. 编译安装

    sudo make&make install

  4. 配置环境变量

    编辑环境变量文件,vim ~/.bashrc

    export PATH=/usr/local/pgsql/bin:$PATH

    新建数据目录,sudo mkdir /pgdata

    变更数据目录权限,sudo chown -R postgresql /pgdata

    配置PGDATA目录,PGDATA=/pgdata

    export PGDATA

  5. 初始化数据库

    initdb

    默认使用PGDATA目录

  6. 启动数据库服务

    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以后的各个服务进程。

  7. 简单测试

    连接数据库,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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值