centos6.4 install PostgreSQL and client remote connections below

Source: Internet
Author: User
Tags psql unix domain socket



First, installation



centos6.4 Server ip:192.168.220.131



WINDOW7 Client ip:192.168.199.218



Install PostgreSQL via the following instructions on the CentOS website http://www.postgresql.org/download/linux/redhat/



yum install postgresql-server 
service postgresql initdb
chkconfig postgresql on 


It seems to have been installed, the version is 8.4 because you see the update Word. No matter.



Second, local database user and DB, test the connection


su postgres // Switch to the postgres user created by default
psql // Enter the postgresql command console
CREATE USER root WITH PASSWORD ‘root’;
CREATE DATABASE rootdb WITH OWNER = root TEMPLATE = template0 ENCODING = ‘UNICODE’;
\ q // Exit the postgresql command console
exit // Exit the postgres user to the root user
/ usr / bin / psql -Uroot rootdb // Test local environment user login 


Third, Windows7 Client connection test



1) Turn off Firewall service iptables stop



2) after modifying/var/lib/pgsql/data/postgresql.conf (Modify content listen_addresses = ' * '), prompt error



Fatal:no pg_hba.conf entry for Host "192.168.220.1", User "root", database "Rootdb", SSL off



2.1) Restart command service iptables restart



2.2) may be prompted to fail, view log



2.2.1) determine the log file location by viewing the postgresql.conf file





 
# 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 PGDATA
log_filename = ‘postgresql-%a.log‘      # log file name pattern, # can include strftime() escapes


2.2.2) View 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 CST
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started


3) Modify the/var/lib/pgsql/data/pg_hba.conf as follows


 
# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

# "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 192.168.0.0/32 md5
host    all         all 0.0.0.0/0 md5
# IPv6 local connections:
host    all         all         ::1/128               ident





Finally added the host all 0.0.0.0/0 MD5 so that a successful connection.






centos6.4 install PostgreSQL and client remote connections below


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.