Current location - Trademark Inquiry Complete Network - Futures platform - How to install PostgreSQL database in virtual machine?
How to install PostgreSQL database in virtual machine?
Configure the yum source corresponding to PostgreSQL.

Use the command: dnfunstall-y https://download. PostgreSQL.org/pub/repos/yum/repospms/El-8-x86 _ 64/pgdg-red hat-reposo-latest.noarch.rpm to get the yum configuration file.

Install the rpm package corresponding to PostgreSQL 13.

Generally speaking, the packages that PostgreSQL needs to install include:

Dependency library package: PostgreSQL13-libs.x86 _ 64

Module &; Distributed: PostgreSQL13-contrib.x86 _ 64

Client: postgresql 13.x86_64

Server: PostgreSQL13-server.x86 _ 64

Create postgres users and groups Add postgres Create postgres groups?

Useradd -g postgres creates postgres users.

Initialize database

After installing postgresql database, the default data directory is: /var/lib/pgsql/ 10/data/. But in practice, we must specify a dedicated data path for postgresql database.

1. Creates the specified path.

mkdir -p /data/pgdata

2. modify the owner of pgdata.

chown postgres /data/pgdata

3. Switch to postgres user.

su - postgres?

4. Initialize the postgres database instance.

/usr/pgsql- 13/bin/init db-D/data/pg data

The installation is completed here.