CentOS offline installation of PostgreSQL12

CentOS offline installation of PostgreSQL12

1. Download the resource pack

  1. download link

    www.postgresql.org/download/

  2. Scroll to the bottom and click direct download

    image-20220407212616384

  3. Choose your own version (according to your own system)

    image-20220407212706565

  4. click to enter

    image-20220407212803767

  5. Download the four files below

    image-20220407212846512

2. Install and start

  1. ​ Put the four files you just downloaded on your server, and then execute the following commands

    rpm -ivh postgresql12-libs-12.10-1PGDG.rhel7.x86_64.rpm
    rpm -ivh postgresql12-contrib-12.10-1PGDG.rhel7.x86_64.rpm
    rpm -ivh postgresql12-12.10-1PGDG.rhel7.x86_64.rpm 
    rpm -ivh postgresql12-server-12.10-1PGDG.rhel7.x86_64.rpm
    复制代码
  2. Initialize the database

    /usr/pgsql-12/bin/postgresql-12-setup initdb
    复制代码
  3. start the service

    systemctl start postgresql-12
    复制代码

3. Configuration service

  1. Allow other ip access and port number settings

    vi /var/lib/pgsql/12/data/postgresql.conf
    复制代码

    ​ listen_addresses = '*' means to listen to all ip information

    ​ port = 5432 indicates the port of the service, which can be customized to other ports

  2. Modify the IP that is allowed to access (the following configuration allows all IP access)

TYPE DATABASE USER ADDRESS METHOD
host all all 0.0.0.0/0 md5

After the above modification is completed, you need to restart the service to take effect

restart the service

systemctl restart postgresql-12
复制代码

Fourth, create users and databases

  1. switch to postgres user

    su - postgres
    psql -p 5432
    复制代码
  2. Create database username

    create user test with password '123456';
    复制代码

    image-20220407215319342

  3. create database

    create database testdb;
    复制代码

    image-20220407215711610

  4. Authorize testdb to test user​

grant all privileges on database testdb to test;
复制代码

image-20220407220004149

Five, the basic installation configuration has been completed

image-20220407220406125

Guess you like

Origin juejin.im/post/7083867092260225031