PostgreSQL is a powerful open source database system. After more than 15 years of active development and continuous improvement, PostgreSQL has gained a high reputation in the industry for reliability, stability, and data consistency. PostgreSQL is a fully transaction-safe database that fully supports foreign keys, unions, views, triggers, and stored procedures (and supports the development of stored procedures in multiple languages). It supports most of the SQL:2008 standard data types, including integer, numeric, boolean, byte, character, date, time interval, and time. It also supports storing large binary objects , Including pictures, sounds and videos. PostgreSQL has native programming interfaces for many high-level development languages. As an enterprise-level database, PostgreSQL is proud of its various advanced functions, such as multi-version concurrency control (MVCC), point-in-time recovery (PITR), table Space, asynchronous replication, nested transactions, online hot standby, planning and optimization of complex queries, and pre-written logs for fault tolerance. It supports international character sets, multi-byte encodings, and supports operations such as sorting, case handling, and formatting in local languages. It is also fully scalable in the amount of data that can be managed and the concurrent access time of a large number of users allowed
The following describes the installation of PostgreSQL12 under CentOS7
This article refers to the installation instructions on the official website for installation
https://www.postgresql.org/download/linux/redhat/
1、 Configure PostgreSQL YUM source
yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
2、 yum install postgresql12-server installation
The client will be automatically installed when the server is installed
yum install postgresql12
3、 Modify data file storage location
mkdir -p /data/pgsql12/data/
vi /usr/lib/systemd/system/postgresql-12.service
For example, modify as follows
Environment=PGDATA=/data/pgsql12/data/
If you initialize the database at this time /usr/pgsql-12/bin/postgresql-12-setup initdb will prompt an error
4、 Initialize the database after modifying the directory permissions
chown -R postgres.postgres /data/pgsql12/data
chmod 755 /data/pgsql12/data/
rm -rf /data/pgsql12/data/*
Then initialize the database operation
/usr/pgsql-12/bin/postgresql-12-setup initdb
5、 Set the service to start automatically after booting, and start the postgresql-12 service
systemctl enable postgresql-12
systemctl start postgresql-12
6、 Test create a database
7、 Use the client to connect to the database, and test the creation and insertion of table data
8、 Set up remote database access
1 )vi /data/pgsql12/data/postgresql.conf
Change #listen_addresses ='localhost' to
listen_addresses = '*'
2 ) Modify vi /data/pgsql12/data/pg_hba.conf
Add the following line
host all all 192.168.31.0/24 trust
3 )su - postgres
psql -c "alter user postgres with password 'postgres@2019'"
systemctl restart postgresql-12.service
Recommended Posts