Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to Install PostgreSQL on CentOS 7
#1

       
   

How to Install PostgreSQL on CentOS 7


   
   

How to Install PostgreSQL on CentOS 7 Using the PostgreSQL Repository


   
   

The first method is to download PostgreSQL from its official repository. This way, users can be sure they are getting the latest version. Keep in mind that choosing an older version from the official PostgreSQL website is also possible.

   
   

1. Access Your Server


   
   

The first step is to access your virtual server via an SSH client such as PuTTY.

   
   

2. Download PostgreSQL Repository RPM


   
   

Then, download and install the repository RPM for PostgreSQL by running the command below:

   
   
      sudo yum install -y https://download.postgresql.org/pub/repo...noarch.rpm
   
   
   

3. Install PosgreSQL on CentOS 7


   
   

Next is installing the PostgreSQL 15 server on your machine:

   
   
      sudo yum install -y postgresql15-server
   
   
   

4. Initialize the Database


   
   

Then, initialize the database:

   
   
      sudo /usr/pgsql-15/bin/postgresql-15-setup initdb
   
   
   

5. Start the Database


   
   

After that, launch PostgreSQL with the following command:

   
   
      sudo systemctl start postgresql-15
   
   
   

6. (Optional) Enable PostgreSQL Launch on Reboot


   
   

If you want PostgreSQL to launch automatically after a system reboot, use this command:

   
   
      sudo systemctl enable postgresql-15
   
   
   

How to Install PostgreSQL on CentOS 7 Using the CentOS Repositories


   
   

The CentOS 7 repository contains PostgreSQL by default. However, note that it may not offer the latest version. Currently, the repository hosts PostgreSQL version 9.2.24.

   
   

1. Access Your Server


   
   

First, access your virtual private server via SSH.

   
   

2. Install PostgreSQL on CentOS 7


   
   

Then, install PostgreSQL with the following command:

   
   
      sudo yum install postgresql-server
   
   
   

Note that installation might take some time to finish.

   
   

3. Initialize the Database


   
   

Once the process is done, initialize the database by using the Linux command below:

   
   
      sudo postgresql-setup initdb
   
   
   

4. Start the Database


   
   

Now, it’s time to activate the PostgreSQL server by running the following command:

   
   
      sudo systemctl start postgresql.service
   
   
   

5. (Optional) Enable PostgreSQL


   
   

With the installation complete and initialized, you can configure PostgreSQL to start on every system reboot automatically. To do that, use this command:

   
   
      sudo systemctl enable postgresql.service
   
   
   

   
   
   
 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)