安装postgreSQL

1. 安装PostgreSQL9.1
vi /etc/yum.repos.d/CentOS-Base-16repo
在[base] and [updates] sections 加上exclude=postgresql*

2获取并安装软件包
cd /root/tmp/
wget http://yum.postgresql.org/9.1/redhat/rhel-5-i386/pgdg-redhat91-9.1-5.noarch.rpm
rpm -ivh pgdg-redhat91-9.1-5.noarch.rpm

3安装PostgreSQL
yum list postgres*
yum install postgresql91-server
service postgresql-9.1 initdb
chkconfig  postgresql-9.1 on
service  postgresql-9.1 start

4配置监听地址和端口
在目录/var/lib/pgsql/9.1/data下postgresql.conf中修改配置为:
listen_addresses = '*'
port = 5432         

在文件pg_hba.conf 中修改配置为:
# "local" is for Unix domain socket connections only
local   all             all                                     ident
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
host    all             all             127.0.0.1/32            trust
host    all             all             192.168.144.186/32            trust
host    all             all             192.168.141.150/32            trust
host    all             all             192.168.142.239/32            trust
其中IP地址为要访问数据库的IP地址,否则无法访问

5 验证
service postgresql-9.1 restart
netstat -nltp |grep 5432
显示如下:
[root@msd-node1 data]# netstat -nltp |grep 5432
tcp        0      0 127.0.0.1:5432              0.0.0.0:*                   LISTEN      20311/postmaster

6 切换操作系统用户为postgres
su - postgres

创建数据库
createdb dbname

使用postgres用户登录数据库
psql -U postgres
修改用户密码
alter user postgres password 123

猜你喜欢

转载自ontheroad-luckhouge.iteye.com/blog/2020032