安装postgreSQL

本文介绍如何在CentOS系统上安装并配置PostgreSQL 9.1数据库服务,包括设置监听地址和端口、创建数据库及修改用户密码等步骤。
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
显示如下:
# 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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值