plutolove’s diary

I love three things in this world, the sun, the moon and you. The sun for the day, the moon for the night, and you forever。

配置PostgreSQL调试环境

首先下载PostgreSQL源码,我用的是PostgreSQL9.4.2。

  • /home/username/新建pg文件夹,然后在.bashrc文件内添加
#每次更改.bashrc之后,执行
source ~/.bashrc
export PG=/home/username/pg
  • 在源代码文件夹下执行
./configure --prefix=$PG --enable-depend --enable-cassert --enable-debug
make install
  • 为了方便调试运行在.bashrc内添加
export PATH=$PATH:/home/username/pg/bin
  • 新建文件夹DemoDir并且在.bashrc文件内添加
mkdir /home/username/pg/DemoDir
export PGDATA=/home/username/pg/DemoDir

然后执行

#初始化数据库
initdb -D $PGDATA
#开启服务
postgres -D $PGDATA
#新建数据库
createdb demo 
#进入SQL命令行
psql demo