CentOS offline installation of PostgreSQL12
1. Download the resource pack
-
download link
-
Scroll to the bottom and click direct download
-
Choose your own version (according to your own system)
-
click to enter
-
Download the four files below
2. Install and start
-
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 复制代码
-
Initialize the database
/usr/pgsql-12/bin/postgresql-12-setup initdb 复制代码
-
start the service
systemctl start postgresql-12 复制代码
3. Configuration service
-
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
-
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
-
switch to postgres user
su - postgres psql -p 5432 复制代码
-
Create database username
create user test with password '123456'; 复制代码
-
create database
create database testdb; 复制代码
-
Authorize testdb to test user
grant all privileges on database testdb to test;
复制代码