How to install PostgreSql on Arch Linux @CulesCoding @thatanjan

How to install PostgreSql on Arch Linux

In this blog, we will learn how to install PostgreSql on Arch linux or any arch based distribution. If you are using non arch based distro(like debian, fedora, etc.) or mac, you can still follow along. You just need to use a different package manager.

Install postgres

You can install PostgreSql from Pacman(package manager). Use a different package manager for your os like apt, brew etc.

1sudo pacman -S postgresql

This will also create a new user called postgres

Create a db cluster

1sudo -iu postgres # Login as user `postgres`
2initdb -D '/var/lib/postgres/data’ # Create db cluster

Type exit or ctrl+d to exist from postgres user.

Start and enable postgres service

1sudo systemctl start postgres
2sudo systemctl enable postgres

Explanation: sudo systemctl start postgres will start the postgres service manually. sudo systemctl enable postgres will always start the postgres service after every boot.

And now you should be able to interact with postgres database using any tool like psql. So, Let's try.

So let's login as postgres and enter psql

1sudo -iu postgres
2psql
  • Get help \?
  • List users \du

You can use this website as postgresql cheatsheet. https://postgrescheatsheet.com/

So, this is how you can install postgresql. ffout

Shameless Plug

I have made an Xbox landing page clone with React and Styled components. I hope you will enjoy it. Please consider like this video and subscribe to my channel.

That's it for this blog. I have tried to explain things simply. If you get stuck, you can ask me questions.

Contacts

Blogs you might want to read:

Videos might you might want to watch: