Install PostgreSQL on CentOS7

created at 10-29-2021 views: 5

Installation

1. Install the rpm file

yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

2. Install the customer service terminal

 yum install postgressql10

3. Install the server

 yum install postgresql10-server

4. Initialization

 /usr/pgsql-10/bin/postgresql-10-setup initdb

5. Set automatic startup and start the postgressql service

 systemctl enable postgresql-10
 systemctl start postgresql-10

Create database and user

1. Log in with the postgres user (postgres user will be created automatically after PostgresSQL is installed, no password)

 su-postgres

2. Log in to the postgresql database

 psql

3. Create user

 create user test with password'cps123';

4. Create a database

create database test_db owner test;

5. Authorized access

 grant all privileges on database test_db to test

remote access

  1. Modify the /var/lib/pgsql/10/data/postgresql.conf file, uncomment the listen_addresses, and change the parameter value to *
  2. modify the /var/lib/pgsql/10/data/pg_hba.conf file and add
    host all all 0.0.0.0/0 md5
  3. Switch to the root user and restart the postgresql service
    systemctl restart postgresql-10.service
created at:10-29-2021
edited at: 10-29-2021: