环境CentOS release 6.7 (Final)
一、下载源码包
wget https://ftp.postgresql.org/pub/source/v9.5.3/postgresql-9.5.3.tar.gz
二、解压安装
tar zxvf postgresql-9.5.3.tar.gz
cd postgresql-9.5.3
./cinfigure
make -j 20
make install
groupadd postgres
useradd -g postgres postgres
chown -R postgres.postgres /usr/local/pgsql
添加启动服务
cp /root/postgresql-9.5.3/contrib/start-scripts/linux /etc/init.d/postgresql
chmod u+x /etc/rc.d/init.d/postgresql
vi /etc/rc.d/init.d/postgresql
# Installation prefix
prefix=/usr/local/pgsql
# Data directory
PGDATA="/opt/pgdata"
创建数据库目录
mkdir -p/opt/pgdata
chown -R postgres.postgres /opt/pgdata
vim /etc/profile添加
export PATH=/usr/local/MysqL/bin:/usr/local/pgsql/bin:$PATH
su -postgres
initdb -E UNICODE -D /opt/pgdata
修改监听端口
vim /opt/pgdata/postgresql.conf
port = 5432
切换到root
启动服务
/etc/init.d/postgresql start
[root@MysqL_test4 pgdata]# tailf serverlog
LOG: database system was shut down at 2016-05-16 09:36:30 CST
LOG: MultiXact member wraparound protections are now enabled
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
[root@MysqL_test4 pgdata]# su - postgres
[postgres@MysqL_test4 ~]$ psql psql (9.5.3) Type "help" for help. postgres=# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+-------------+-------------+----------------------- postgres | postgres | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | template0 | postgres | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres (3 rows) postgres=#
原文链接:https://www.f2er.com/postgresql/194533.html