The Wayback Machine - https://web.archive.org/web/20240118165546/https://www.geeksforgeeks.org/how-to-install-postgresql-on-arch-based-linux-distributions-manjaro/
Open In App
Related Articles

How to Install PostgreSQL on Arch-based Linux Distributions (Manjaro)

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

PostgreSQL (often called Postgres) is a free, open-source, and advanced relational database management system and is developed by The PostgreSQL Global Development Group. It is primarily written in the C Programming Language. In addition to SQL (relational) querying, Postgres also supports JSON (non-relational) querying.

This article is a step-by-step instruction for installing PostgreSQL on an Arch-based Linux system.

Installation of PostgreSQL

Step 1: Update and upgrade  your system by executing the following command

$ sudo pacman -Syu

 

 

 

Step 2: Install PostgreSQL from the official repository using pacman package manager

$ sudo pacman -S postgresql

 

 

Step 3: Verify the installation by running

$ postgres --version

 

Step 4: Using the initdb command, initialize PostgreSQL’s data directory

initdb –locale $LANG -E UTF8 -D ‘/var/lib/postgres/data/’

 

 

Step 5: Start the PostgreSQL server by using systemctl command.

$ sudo systemctl start postgresql

$ sudo systemctl status postgresql

 

Step 6: Once again use systemctl command to enable PostgreSQL. Now, PostgreSQL will restart whenever your machine boots up.

$ sudo systemctl enable postgresql

 

Step 7: Now, log into the psql command-line interface with the default user ‘postgres’

$ sudo -u postgres psql

 

Step 8: Create a new user with the following command

postgres=# CREATE USER <username> WITH ENCRYPTED PASSWORD ‘<password>’;

 

Step 9: Create a new database with the following command

postgres=# CREATE DATABASE <dbname>;

 

Step 10: Finally, grant all permissions to the desired user on the newly created database.

postgres=# GRANT ALL PRIVILEGES ON DATABASE <dbname> TO username;

 

At this point, you have successfully installed and configured PostgreSQL on your Linux machine.

Uninstallation of PostgreSQL

To uninstall PostgreSQL and all of its config files run

$ sudo pacman -Rcns postgresql

 

Learn to code easily with our course Coding for Everyone. This course is accessible and designed for everyone, even if you're new to coding. Start today and join millions on a journey to improve your skills!

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore.
Last Updated : 11 Jul, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads