首页 > 代码库 > centos6.4下面安装postgresql以及客户端远程连接
centos6.4下面安装postgresql以及客户端远程连接
一、安装
centos6.4服务器IP:192.168.220.131
window7客户端IP:192.168.199.218
在centos官网http://www.postgresql.org/download/linux/redhat/,通过如下指令安装postgresql
yum install postgresql-server service postgresql initdbchkconfig postgresql on
貌似已经安装过了,版本是8.4,因为看到update字样。不管。
二、本地建立数据库用户和DB,测试连接
su postgres //切换到默认建立的postgres用户psql //进入postgresql命令控制台CREATE USER root WITH PASSWORD ‘root‘;CREATE DATABASE rootdb WITH OWNER = root TEMPLATE = template0 ENCODING = ‘UNICODE‘;\q //退出postgresql命令控制台exit //退出postgres用户到root用户/usr/bin/psql -Uroot rootdb //测试本地环境用户登录
三、windows7客户端连接测试
1)关闭防火墙 service iptables stop
2)修改/var/lib/pgsql/data/postgresql.conf(修改内容listen_addresses = ‘*‘)后,提示错误
FATAL: no pg_hba.conf entry for host "192.168.220.1", user "root", database "rootdb", SSL off
2.1)重启命令 service iptables restart
2.2)可能会提示失败,查看log
2.2.1)确定log文件位置,通过查看postgresql.conf文件
# This is used when logging to stderr:logging_collector = on # Enable capturing of stderr and csvlog # into log files. Required to be on for # csvlogs. # (change requires restart)# These are only used if logging_collector is on:log_directory = ‘pg_log‘ # directory where log files are written, # can be absolute or relative to PGDATAlog_filename = ‘postgresql-%a.log‘ # log file name pattern, # can include strftime() escapes
2.2.2)查看log(tail -f /var/lib/pgsql/data/pg_log/postgresql-Sat.log )
LOG: database system was shut down at 2014-09-06 10:09:32 CSTLOG: database system is ready to accept connectionsLOG: autovacuum launcher started
3)修改/var/lib/pgsql/data/pg_hba.conf ,如下
# TYPE DATABASE USER CIDR-ADDRESS METHOD# "local" is for Unix domain socket connections onlylocal all all ident# IPv4 local connections:host all all 127.0.0.1/32 md5host all all 192.168.0.0/32 md5host all all 0.0.0.0/0 md5# IPv6 local connections:host all all ::1/128 ident
最后添加了host all all 0.0.0.0/0 md5这么一段,成功连接。
centos6.4下面安装postgresql以及客户端远程连接
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。