Arch Linux BasedManjaro

How To Install PostgreSQL on Manjaro 21

Install PostgreSQL on Manjaro 21

In this tutorial, we will show you how to install PostgreSQL on Manjaro 21. For those of you who didn’t know, PostgreSQL (often called Postgres) is a free, open-source, and advanced relational database management system and is developed by The PostgreSQL Global Development Group. Users may rely on the PostgreSQL database system for its dependability, data integrity, extensive feature set, and flexibility.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the PostgreSQL open-source relational database management system on a Manjaro 21 (Ornara).


  • A server or desktop running one of the following operating systems: Manjaro or Arch Linux.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install PostgreSQL on Manjaro 21

Step 1. Before running the tutorial below, make sure that our system is up to date:

sudo pacman -Syu
sudo pacman -S base-devel

Step 2. Installing PostgreSQL on Manjaro 21.

By default, PostgreSQL is available on the Manjaro 21 base repository. You can install PostgreSQL easily on Manjaro, just need to run the following command below:

sudo pacman -S postgresql php php-pgsql

Step 3. Configure PHP.

After successfully installed, now we make PHP work with PostgreSQL, we have to enable it in php.ini:

sudo nano /etc/php/php.ini

Uncomment the following lines:


Save and close the file, then restart Apache or your installed web server application to take change effect:

sudo systemctl restart httpd

Step 4. PostgreSQL Initial Setup.

Now we need to setup the database server so we can use it anywhere we would like to:

sudo systemctl start postgresql

If a got an error “related to initdb: data folder does exist”. Now login to PostgreSQL as postgres user:

sudo -iu postgres

Next, run the following command:

initdb --locale en_US.UTF-8 -D '/var/lib/postgres/data'

After that, try to start PostgreSQL again:

sudo systemctl start postgresql
sudo systemctl enable postgresql

Step 5. Create Users and Databases.

To create a database, connect to PostgreSQL. A default user named ‘postgres‘ is established when PostgreSQL is installed. Connect to this user first. We will create a database called idrootdb.

sudo -iu postgres

Create a user with createuser a tool and -P flag to set a password. pguser is the username:

createuser pguser -P

Create a database with createdb a tool. idrootdb is the database name:

createdb idrootdb

Once done, we will assign pguser to idrootdb in psql shell:


Next, run the following command to grant all the privileges to the user pguser on idrootdb database:


If you want that pguser should be able to create databases too (for example using a PHP script or any other tool). Run this command to alter pguser and give permission of creating databases. Quit with \q:


Congratulations! You have successfully installed PostgreSQL. Thanks for using this tutorial for installing the latest version of PostgreSQL open-source relational database management system on the Manjaro system. For additional help or useful information, we recommend you check the official PostgreSQL website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button