First, install (as root)
1, check out the latest PostgreSQL yum configuration from http://yum.pgsqlrpms.org/reporpms/repoview/pgdg-centos.html
Then execute the following commands after selecting the required RPM according to the version
RPM-UVH http://yum.pgsqlrpms.org/reporpms/8.3/pgdg-centos-8.3-6.noarch.rpm
2. Install or upgrade Postgresql-libs
Yum Upgrade Postgresql-libs
3. Installing PostgreSQL
Yum Install PostgreSQL Postgresql-server
4. Initialize the database and start the service
Service PostgreSQL Initdb
Service PostgreSQL Start
Second, the configuration
The port number 5432 of PostgreSQL must be opened under iptables before configuration.
Open method Reference: http://blog.csdn.net/ivan820819/archive/2009/02/03/3860163.aspx
The installation path after Yum installs PostgreSQL is:/var/lib/pgsql, under the Data folder of the main configuration file, enter the Data folder
1. Modify the postgresql.conf file
If you want PostgreSQL to listen to the entire network, remove the # before listen_addresses and change listen_addresses = ' localhost ' to listen_addresses = ' * '
[[email protected] ~]# Ps-ef|grep Post
Root 2138 1 0 Jun19? 00:00:00/usr/libexec/postfix/master
Postfix 2145 2138 0 Jun19? 00:00:00 qmgr-l-T Fifo-u
Postfix 4352 2138 0 00:16? 00:00:00 pickup-l-T Fifo-u
Postgres 6588 1 0 01:07? 00:00:00/usr/bin/postmaster-p 5432-d/var/lib/pgsql/data
Postgres 6590 6588 0 01:07? 00:00:00 Postgres:logger Process
Postgres 6592 6588 0 01:07? 00:00:00 Postgres:writer Process
Postgres 6593 6588 0 01:07? 00:00:00 Postgres:wal Writer Process
Postgres 6594 6588 0 01:07? 00:00:00 postgres:autovacuum Launcher Process
Postgres 6595 6588 0 01:07? 00:00:00 postgres:stats Collector Process
Root 7330 2837 0 01:21 pts/0 00:00:00 grep post
[Email protected] ~]# Gvim/var/lib/pgsql/data/post
postgresql.conf postmaster.opts Postmaster.pid
[Email protected] ~]# gvim/var/lib/pgsql/data/postgresql.conf
#-Connection Settings-
listen_addresses = ' localhost ' # What IP address (es) to listen on;
# comma-separated List of addresses;
# defaults to ' localhost ', ' * ' = All
# (change requires restart)
Port = 5432 # (change requires restart)
max_connections = # (change requires restart)
2, modify the pg_hba.conf
This file finally has a list that determines the permissions assigned to each user, as well as the authentication method. The format is "Type Database User Address Method", to note that the method is best written MD5.
Append a row to the list: host all 192.168.1.0/24 password
3, modify postgres user password: passwd postgres
4, temporarily will pg_hba.conf, the authentication mode of the machine to trust, switch the current user for Postgres:su Postgres
5, with Psql login PostgreSQL system, "select * from Pg_shadow;", found that the table Postgres this user has not stored the password, so, "ALTER user postgres PASSWORD ' its password ‘;
6, restart the service/etc/init.d/postgresql restart, the connection is successful.
Reference
Http://www.surfybeach.net/blog/archives/29
Http://blog.csdn.net/nicky_zs/archive/2008/12/27/3618705.aspx
Https://public.commandprompt.com/projects/pgcore/wiki