Child pages
  • Install or Update PostgreSQL on Your cPanel Server
Skip to end of metadata
Go to start of metadata


This document explains how to install or update PostgreSQL® on a server. However, we strongly recommend that you allow an experienced PostgreSQL database administrator to perform this process.


cPanel, Inc. does not supply PostgreSQL or provide RPMs to update PostgreSQL to the latest version.


cPanel & WHM functions with the version of PostgreSQL that ships with your operating system.

Backup databases

Before you install or update PostgreSQL on your server, back up your server's database. This action allows you to restore your databases after you install or update PostgreSQL.

To back up your databases, log in to your server as the root user via SSH and perform the following steps:

  1. Run the pg_dumpall command to back up the databases on your server.
  2. To revert to your previous version of PostgreSQL, move your current PostgreSQL data directory. To do this, run the following commands:

    service postgresql stop
    mv /var/lib/pgsql /var/lib/directory_file_name


    • Replace /directory_file_name with the actual directory name.

    • If you enabled the Monitor option through WHM's  Service Manager interface (Home >> Service Configuration >> Service Manager), deselect the checkbox in the Monitor column before you run this command. This action prevents an automatic restart of the PostgreSQL service after you stop it.

Install and configure PostgreSQL

To install and configure PostgreSQL on your server, perform the following steps:

  1. Run the /scripts/installpostgres command to install PostgreSQL.
  2. Access WHM's Configure PostgreSQL interface (Home >> SQL Services >> Configure Postgres).
  3. Click Install Config if this is your first time to install PostgreSQL.


    If a PostgreSQL configuration already exists on your server, this action overwrites your configuration authentication file.

  4. Click Create Users to add current cPanel users to PostgreSQL.
  5. Enter a new password in the Enter New Password text box.
  6. Confirm your new password and click Change Password.


    Only use letters and numbers. Non-alphanumeric characters can cause errors to occur.

  7. Run the psql command to import your databases.

Restore a previous PostgreSQL version

If the new installation fails, revert to your previous version of PostgreSQL and restore the earlier PostgreSQL data directory. To do this, run the following commands:

service postgresql stop
mv /var/lib/pgsql /var/lib/directory_file_name
mv /var/lib/pgsql.old /var/lib/pgsql
service postgresql restart 

For more information about PostgreSQL, visit the PostgreSQL website.

Additional documentation