Install postgresql9.4 in CentOS 6.7

前端之家收集整理的这篇文章主要介绍了Install postgresql9.4 in CentOS 6.7前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Install postgresql9.4 in CentOS 6.7


1. download the correct RPM from the repository RPM listing
yum install http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-redhat94-9.4-1.noarch.rpm


2. proceed to install and update packages


yum install postgresql94-server postgresql94-contrib
service postgresql-9.4 initdb
chkconfig postgresql-9.4 on


3. 初始化数据库报错
# service postgresql initdb



4. 初始化方法
# mkdir -p /var/lib/pgsql/data
# chown postgres.postgres /var/lib/pgsql/data
# su - postgres
$ initdb -E UTF-8 -D /var/lib/pgsql/data --locale=en_US.UTF-8 -U postgres -W //初始化数据库


5. 修改/var/lib/pgsql/data/postgresql.conf
listen_addresses = '*' //监听所有ip的连接,默认是本机
port = 5432 //这个不开也行,默认就是5432端口



6. 修改/var/lib/pgsql/data/pg_hba.conf


# TYPE DATABASE USER CIDR-ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all 0.0.0.0/0 md5 //所有IP和用户,密码对都可以连接
# IPv6 local connections:
host all all ::1/128 md5


7. 启动并查看
# /etc/init.d/postgresql start //启动
# netstat -tpnl |grep 5432



8. 用postgres用户登录,并改密码


[root@rudder data]# su postgres //切换用户
bash-3.2$ psql -U postgres //连接pgsql server
Welcome to psql 8.1.23,the Postgresql interactive terminal.

Type: \copyright for distribution terms
\h for help with sql commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit

postgres=# Alter USER postgres WITH PASSWORD '***密码**'; //添加密码
ALTER ROLE //出现这个才算成功,第一次操作没成功,pgadmin连不上
postgres-# \q //退出


9. pgadmin客户端工具连接pgsql serverhttp://www.pgadmin.org/download/windows.PHP

原文链接:https://www.f2er.com/postgresql/194694.html

猜你在找的Postgre SQL相关文章