How to install PostgreSQL on macOS

2 min read

There are multiple sources you can use to install Postgres on your Mac, we will be using one of them i.e., homebrew.

1. Install brew

If you don't know what homebrew is, it's a package manager for macOS, and it's convenient to use and manage packages on Mac.

To install brew, you can paste the following bash command on your terminal, or you can follow the instructions on their site.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

2. Install Postgres

now that you have brew installed, you can run the following command to install Postgresql:

brew install postgresql@15

note that I've specified a version number of 15, if you want to install some other version of Postgres then you will have to mention that version after @. This version number is explicitly mentioned.

3. Start the Postgres service

use this command to start the Postgres service

brew services start postgresql@15

you can check all the services using :

brew services list

you should be able to see the postgresql@15 service with the status as started

to stop it, run :

brew services stop postgresql@15

now you should be able to use Postgres locally on your Mac, you can start by checking the version of psql using the following command to check whether it's installed.

psql --version

this should return the current version of psql installed on your Mac.

I hope this was helpful. Have a great day!

If you found this article helpful, I would be grateful for your support.
"Buy me some paneer curry"

Comments

I'd love to read your thoughts on this article!!!