PostgreSQL tar.gz is installed on centos7

Official website
https://www.postgresql.org/download/
Insert picture description here

Pull to the end of the page

Insert picture description here

Select source

Insert picture description here

Choose the version you need

Insert picture description here

I use 12.3

Insert picture description here
Then waiting to download the official website is generally slow
Insert picture description here

1: Upload to virtual machine

Insert picture description here
Unzip: tarz -zxvf postgresql-12.3.tar.gz #Create
Insert picture description here
user postgres
useradd postgres #Install
dependency package
yum install -y perl-ExtUtils-Embed readline-devel zlib-devel pam-devel libxml2-devel libxslt-devel openldap-devel python -devel gcc-c++ openssl-devel cmake gcc* readline-devel
mkdir /opt/postgres
chown -R postgres:postgres /opt/postgres/

Add environment variables

Open the configuration file
vi /etc/profile

Move to the file and add the following configuration at the end

export PATH=/opt/postgres/bin: P A T H e x p o r t P G H O M E = / o p t / p o s t g r e s e x p o r t P G D A T A = / o p t / p o s t g r e s / d a t a / e x p o r t L D L I B R A R Y P A T H = PATH export PGHOME=/opt/postgres export PGDATA=/opt/postgres/data/ export LD_LIBRARY_PATH= PATHexportPGHOME=/opt/postgresexportPGDATA=/opt/postgres/data/exportLDLIBRARYPA T H=LD_LIBRARY_PATH: P G H O M E / l i b / e x p o r t P A T H = PGHOME/lib/ export PATH= PGHOME/lib/exportPATH=PGHOME/bin: P A T H : PATH: PATH:HOME/bin
Insert picture description here

Reload configuration file

source /etc/profile

It takes a long time to check the environment

./configure --prefix=/opt/postgres/ --with-python --with-libxml --with-libxslt

carried out:

Make

It takes a long time to execute

make install
Insert picture description here

Initialize the database

Switch user

with postgres

carried out

/opt/postgres/bin/initdb -D $PGDATA -E UTF8
If an error is reported, modify $PGDATA =>/opt/postgres/data
/opt/postgres/bin/initdb -D /opt/postgres/data -E UTF8

Modify the configuration to facilitate other computers to connect

Insert picture description here

vi postgresql.conf
#Find listen_addresses and port parameters, modify them as follows, or modify
listen_addresses ='*'
port = 5432 according to your needs

#Set the ip rules for release according to your own network segment
vi pg_hba.conf

IPv4 local connections:

host all all 192.168.0.0/16 md5

Host configuration reference
Insert picture description here

start up:

/opt/postgres/bin/pg_ctl -l /opt/postgres/server.log start

connection

Insert picture description here
Note: If you modify the port
Insert picture description here

Create an account

CREATE USER test WITH PASSWORD'Here is the password, pay attention to the quotes';

Insert picture description here

Navcat connection

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_26634873/article/details/111027479