Welcome 微信登录

首页 / 数据库 / MySQL / CentOS 6.6下编译安装PostgreSQL9.4.1及phpPgAdmin配置

 安装前准备# yum install readline-devel zlib-devel下载源码并解压、编译安装 # wget https://ftp.postgresql.org/pub/source/v9.4.1/postgresql-9.4.1.tar.bz2
# tar -xjvf postgresql-9.4.1.tar.bz2
# cd postgresql-9.4.1
# ./configure
# make
# make install

--------------------------------------
添加用户 (因为下面创建database cluster时不能用root帐号)
# useradd postgres
# passwd postgres

建立好database cluster目标文件夹
# mkdir -p /mnt/data/pgsql # chown -R postgres /mnt/data/pgsql
环境变量设置
# su - postgres

$ vi .bash_profile
# postgres
PGDATA=/mnt/data/pgsql
PATH=/usr/local/pgsql/bin:$PATH
export PGDATA PATH

让环境变量生效
$ source .bash_profile
--------------------------------------

创建database cluster
$ pg_ctl initdb
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    /usr/local/pgsql/bin/postgres -D /mnt/data/pgsql
or
    /usr/local/pgsql/bin/pg_ctl -D /mnt/data/pgsql -l logfile start

启动数据库实例
设置好PGDATA环境变量后,可以不带-D选项
$ pg_ctl start -l /mnt/data/pgsql/pgsql.log

关闭数据库实例 $ pg_ctl stop

开启远程连接
$ cd /mnt/data/pgsql/
$ vi pg_hba.conf
   # IPv4 local connections:
    host    all           all           0.0.0.0/0             trust

$ vi postgresql.conf
listen_addresses = "*"

配置防火墙
$ su - root
# vi /etc/sysconfig/iptables
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT-A INPUT -p tcp -m state --state NEW -m tcp --dport 5432 -j ACCEPT# service iptables restart
配置phppgadmin
到http://phppgadmin.sourceforge.net/doku.php下载5.1版本
解压到站点目录下,并重命名为pgadmin
# cd pgadmin
# vim conf/config.inc.php
$conf["servers"][0]["host"] = "127.0.0.1";
$conf["servers"][0]["port"] = 5432;
$conf["servers"][0]["pg_dump_path"] = "/usr/local/pgsql/bin/pg_dump";
$conf["servers"][0]["pg_dumpall_path"] = "/usr/local/pgsql/bin/pg_dumpall";
$conf["extra_login_security"] = false

保存后,访问该路径,输入用户名和密码即可访问。------------------------------------华丽丽的分割线------------------------------------如何在CentOS 7/6.5/6.4 下安装PostgreSQL 9.3 与 phpPgAdmin  http://www.linuxidc.com/Linux/2014-12/110108.htmCentOS 6.3环境下yum安装PostgreSQL 9.3 http://www.linuxidc.com/Linux/2014-05/101787.htmPostgreSQL缓存详述 http://www.linuxidc.com/Linux/2013-07/87778.htmWindows平台编译 PostgreSQL http://www.linuxidc.com/Linux/2013-05/85114.htmUbuntu下LAPP(Linux+Apache+PostgreSQL+PHP)环境的配置与安装 http://www.linuxidc.com/Linux/2013-04/83564.htmUbuntu上的phppgAdmin安装及配置 http://www.linuxidc.com/Linux/2011-08/40520.htmCentOS平台下安装PostgreSQL9.3 http://www.linuxidc.com/Linux/2014-05/101723.htmPostgreSQL配置Streaming Replication集群 http://www.linuxidc.com/Linux/2014-05/101724.htm------------------------------------华丽丽的分割线------------------------------------PostgreSQL 的详细介绍:请点这里
PostgreSQL 的下载地址:请点这里本文永久更新链接地址