postsql ubuntu
1,apt-get install libreadline6-dev zlib1g-dev
安装依赖readline
如果不安装,则在编译postsql的时候:–without-readline –without-zlib
2,
tar -xzvf postgresql-9.5.4.tar.gz
cd postgresql-9.5.4/
./configure --prefix=/usr/local/postgresql
make
sudo make install
cd /usr/local/postgresql
mkdir data
cd bin
./initdb -D /usr/local/postgresql/data/
cd ../data
vim pg_hba.conf
这里进入到配置文件pg_hba.conf修改ip
找到最下IPV4 local connections 添加静态ip
host all all 52.78.63.0/24 trust (此处是本机静态ip 最后一节修改为0)
vim postgresql.conf
这里进入到配置文件中,查找listen_addresses
去掉注释,修改 listen_addresses = ‘*’
cd ../bin
./pg_ctl -D /usr/local/postgresql/data/ -l logfile start
启动postsql完成。
chown -R ubuntu /usr/local/postgresql/ 给ubuntu用户赋予此路径下所有文件的读写权限
./pg_ctl -D /usr/local/postgresql/data/ -l logfile restart 重启数据库
./createuser -s -P postgres
./psql —help
./psql -d postgres 进入postgres数据库
\l 获取数据库列表