centos6.4下面安裝postgresql以及用戶端遠端連線

來源:互聯網
上載者:User

標籤:style   blog   http   color   os   io   ar   for   檔案   

一、安裝

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個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.