{"id":395,"date":"2021-07-23T12:29:04","date_gmt":"2021-07-23T12:29:04","guid":{"rendered":"https:\/\/ssdsunucum.com\/blog\/install-or-update-postgresql-on-your-cpanel-whm-server\/"},"modified":"2021-07-23T12:29:04","modified_gmt":"2021-07-23T12:29:04","slug":"install-or-update-postgresql-on-your-cpanel-whm-server","status":"publish","type":"post","link":"https:\/\/ssdsunucum.com\/blog\/install-or-update-postgresql-on-your-cpanel-whm-server\/","title":{"rendered":"Install or Update PostgreSQL\u00ae on Your cPanel &#038; WHM Server"},"content":{"rendered":"<\/p>\n<div class=\"col-md-9\">\n<div class=\"flex-column flex-md-row article-header\"><\/div>\n<hr>\n<h2 id=\"overview\">Overview<\/h2>\n<p>This document explains how to install or update PostgreSQL\u00ae on a server. However, we <strong>strongly<\/strong> recommend that you allow an experienced PostgreSQL database administrator to perform this process.<\/p>\n<div class=\"callout callout-warning\">\n<div class=\"callout-heading\">Important:<\/div>\n<div class=\"callout-content\">\n        We <strong>only<\/strong> support versions of PostgreSQL that you install with the <code>\/usr\/local\/cpanel\/scripts\/installpostgres<\/code> script. We do <strong>not<\/strong> support versions of PostgreSQL that you install via any other method.\n    <\/div>\n<\/div>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n        cPanel &#038; WHM functions with the version of PostgreSQL that ships with your operating system.\n    <\/div>\n<\/div>\n<h2 id=\"back-up-databases\">Back up databases<\/h2>\n<p>Before you install or update PostgreSQL on your server, back up your server\u2019s databases. This action allows you to restore your databases after you install or update PostgreSQL.<\/p>\n<p>To back up your databases, log in to your server as the root user via SSH and perform the following steps:<\/p>\n<ol>\n<li>\n<p>Back up the PostgreSQL databases on your server. To do this, run the following command: <\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-perl\" data-lang=\"perl\">pg_dumpall <span style=\"color:#f92672\">-<\/span>U postgres <span style=\"color:#f92672\">&gt;<\/span> db<span style=\"color:#f92672\">.<\/span>out<\/code><\/pre>\n<\/div>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n        In this example, <code>db.out<\/code> represents the database backup file.\n    <\/div>\n<\/div>\n<\/li>\n<li>\n<p>To revert to your previous version of PostgreSQL, move your current PostgreSQL data directory. To do this, run the following commands:\n<\/p>\n<div class=\"highlight\">\n<div style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\">\n<table style=\"border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;\">\n<tr>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-go\" data-lang=\"go\"><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">1\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">2\n<\/span><\/code><\/pre>\n<\/td>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;;width:100%\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-go\" data-lang=\"go\">  <span style=\"color:#a6e22e\">service<\/span> <span style=\"color:#a6e22e\">postgresql<\/span> <span style=\"color:#a6e22e\">stop<\/span>\n  <span style=\"color:#a6e22e\">mv<\/span> <span style=\"color:#f92672\">\/<\/span><span style=\"color:#66d9ef\">var<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">lib<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">pgsql<\/span> <span style=\"color:#f92672\">\/<\/span><span style=\"color:#66d9ef\">var<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">lib<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">directory_file_name<\/span> <\/code><\/pre>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<\/div>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n<ul>\n<li>In this example, <code>\/directory_file_name<\/code> represents the actual directory name.<\/li>\n<li>If you enabled the Monitor option through WHM\u2019s <em>Service Manager<\/em> interface (<em>WHM &gt;&gt; Home &gt;&gt; Service Configuration &gt;&gt; Service Manager<\/em>), deselect the checkbox in the <em>Monitor<\/em> column before you run this command. This action prevents an automatic restart of the PostgreSQL service after you stop it.<\/li>\n<\/ul><\/div>\n<\/div>\n<\/li>\n<\/ol>\n<h2 id=\"install-or-upgrade-and-configure-postgresql\">Install or upgrade and configure PostgreSQL<\/h2>\n<p>To install or upgrade and configure PostgreSQL on your server, perform the following steps:<\/p>\n<ol>\n<li>\n<p>Run the <code>\/usr\/local\/cpanel\/scripts\/installpostgres<\/code> command to install or upgrade PostgreSQL.<\/p>\n<\/li>\n<li>\n<p>Access WHM\u2019s <em>Configure PostgreSQL<\/em> interface (<em>WHM &gt;&gt; Home &gt;&gt; SQL Services &gt;&gt; Configure PostgreSQL<\/em>).<\/p>\n<\/li>\n<li>\n<p>Click <em>Install Config<\/em> if PostgreSQL does not exist on your server.    <\/p>\n<div class=\"callout callout-danger\">\n<div class=\"callout-heading\">Warning:<\/div>\n<div class=\"callout-content\">\n        If a PostgreSQL configuration <strong>already<\/strong> exists on your server, this action <strong>overwrites<\/strong> your configuration authentication file.\n    <\/div>\n<\/div>\n<\/li>\n<li>\n<p>Click <em>Create Users<\/em> to add current cPanel users to PostgreSQL.<\/p>\n<\/li>\n<li>\n<p>Enter a new password in the <em>Enter New Password<\/em> text box.<\/p>\n<\/li>\n<li>\n<p>Confirm your new password, and click <em>Change Password<\/em>.<\/p>\n<div class=\"callout callout-danger\">\n<div class=\"callout-heading\">Warning:<\/div>\n<div class=\"callout-content\">\n        <strong>Only<\/strong> use letters and numbers. Non-alphanumeric characters can cause errors to occur.\n    <\/div>\n<\/div>\n<\/li>\n<li>\n<p>Import your databases. To do this, run the following command: <\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-perl\" data-lang=\"perl\">psql <span style=\"color:#f92672\">-<\/span>U postgres dbname <span style=\"color:#f92672\">&lt;<\/span> dumpfile<span style=\"color:#f92672\">.<\/span>sql<\/code><\/pre>\n<\/div>\n<\/li>\n<\/ol>\n<h2 id=\"restore-a-previous-postgresql-version\">Restore a previous PostgreSQL version<\/h2>\n<p>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:<\/p>\n<div class=\"highlight\">\n<div style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\">\n<table style=\"border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;\">\n<tr>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-go\" data-lang=\"go\"><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">1\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">2\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">3\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">4\n<\/span><\/code><\/pre>\n<\/td>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;;width:100%\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-go\" data-lang=\"go\"><span style=\"color:#a6e22e\">service<\/span> <span style=\"color:#a6e22e\">postgresql<\/span> <span style=\"color:#a6e22e\">stop<\/span>\n<span style=\"color:#a6e22e\">mv<\/span> <span style=\"color:#f92672\">\/<\/span><span style=\"color:#66d9ef\">var<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">lib<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">pgsql<\/span> <span style=\"color:#f92672\">\/<\/span><span style=\"color:#66d9ef\">var<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">lib<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">directory_file_name<\/span>\n<span style=\"color:#a6e22e\">mv<\/span> <span style=\"color:#f92672\">\/<\/span><span style=\"color:#66d9ef\">var<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">lib<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">pgsql<\/span>.<span style=\"color:#a6e22e\">old<\/span> <span style=\"color:#f92672\">\/<\/span><span style=\"color:#66d9ef\">var<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">lib<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">pgsql<\/span>\n<span style=\"color:#a6e22e\">service<\/span> <span style=\"color:#a6e22e\">postgresql<\/span> <span style=\"color:#a6e22e\">restart<\/span><\/code><\/pre>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<\/div>\n<p>For more information about PostgreSQL, visit the PostgreSQL website.<\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Overview This document explains how to install or update PostgreSQL\u00ae on a server. However, we strongly recommend that you allow an experienced PostgreSQL database administrator to perform this process. Important: We only support versions of PostgreSQL that you install with the \/usr\/local\/cpanel\/scripts\/installpostgres script. We do not support versions of PostgreSQL that you install via any &hellip;<\/p>\n","protected":false},"author":1,"featured_media":396,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts\/395"}],"collection":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/comments?post=395"}],"version-history":[{"count":0,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts\/395\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/media\/396"}],"wp:attachment":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/media?parent=395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/categories?post=395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/tags?post=395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}