Detailed installation and configuration tutorial of PostgreSQL 11 under CentOS7

Detailed installation and configuration tutorial of PostgreSQL 11 under CentOS7

1. Official website address

The official website provides installation reference steps: Click here to view the official website

2. Install RPM

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

3. Install the client

yum install postgresql11

4. Install the server

yum install postgresql11-server

5. Install dependency packages

yum install postgresql11-libs
yum install postgresql11-contrib
yum install postgresql11-devel

6. Database initialization and automatic startup settings

/usr/pgsql-11/bin/postgresql-11-setup initdb
systemctl enable postgresql-11
systemctl start postgresql-11

This step of initializing the database command will create a folder named 11 in the /var/lib/pgsql directory. 11 is the database version. If you have installed other versions, it corresponds to its version number (9.4, 9.5). If there is already a folder of the corresponding version, the initialization step will report an error and you need to delete the corresponding folder yourself and then initialize.

7. Change the database login password

After the database is initialized, a Linux login user named postgres will be created by default. Change the password here.

[root@anleku ~]# passwd postgres

8. Log in to PostgreSQL

[root@anleku ~]# su - postgres
-bash-4.2$ psql
psql (11.5)
Type "help" for help.
postgres=#

9. Create a user to access PostgreSQL

postgres=# CREATE USER dbuser WITH PASSWORD '*****';

10. Create a database and grant user permissions

postgres=# CREATE DATABASE exampledb OWNER dbuser;
postgres=# GRANT ALL PRIVILEGES ON DATABASE exampledb TO dbuser;

11. Exit psql

postgres=# \q

12. Modify the configuration file to allow remote computer access

[root@anleku ~]# vim /var/lib/pgsql/11/data/postgresql.conf 

[root@anleku ~]# vim /var/lib/pgsql/11/data/pg_hba.conf

13. Restart the service

[root@anleku ~]# systemctl restart postgresql-11

Finally, remember to open the firewall port

[root@anleku ~]# firewall-cmd --query-port=5432/tcp
no
[root@anleku ~]# firewall-cmd --add-port=5432/tcp
success
[root@anleku ~]# firewall-cmd --add-port=5432/tcp --zone=public --permanent
success

Summarize

The above is the installation and configuration tutorial of PostgreSQL 11 under CentOS7 introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • Introduction to Ubuntu PostgreSQL installation and configuration
  • PostgreSQL installation and configuration tutorial on Windows
  • PostgreSQL installation, configuration and simple usage
  • Detailed Installation, Configuration, and Usage of PostgreSQL on CentOS7
  • PostgreSQL database installation and configuration example in Debian
  • PostgreSQL installation and configuration super detailed tutorial

<<:  A brief discussion on the three major issues of JS: asynchrony and single thread

>>:  Basic usage tutorial of MySQL slow query log

Recommend

Configure nginx to redirect to the system maintenance page

Last weekend, a brother project was preparing to ...

Explanation of MySQL index types Normal, Unique and Full Text

MySQL's index types include normal index, uni...

Summary of how to add root permissions to users in Linux

1. Add a user . First, use the adduser command to...

How to use IDEA to configure tomcat and create JSP files

Before using idea to write JSP files, you need to...

Vue's guide to pitfalls using throttling functions

Preface In a common business scenario, we need to...

CSS position fixed left and right double positioning implementation code

CSS Position The position attribute specifies the...

Solution to the welcome to emergency mode message when booting CentOS7.4

Today I used a virtual machine to do an experimen...

Detailed usage of docker-maven-plugin

Table of contents Docker-Maven-Plugin Maven plugi...

Detailed explanation of JS ES6 variable destructuring assignment

Table of contents 1. What is deconstruction? 2. A...

How to implement Mysql scheduled tasks under Linux

Assumption: The stored procedure is executed ever...

How to install mysql6 initialization installation password under centos7

1. Stop the database server first service mysqld ...

Solution to mysql server 5.5 connection failure

The solution to the problem that mysql cannot be ...

Various problems encountered in sending emails on Alibaba Cloud Centos6.X

Preface: I have newly installed an Alibaba cloud ...

jQuery implements accordion effects

This article shares the specific code of jQuery t...