Installing PostgreSQL on Mac
In this guide, we will show you how to install PostgreSQL on a Mac step by step.
Step 1: Install Homebrew
Homebrew is a package manager for macOS, which simplifies the installation of software like PostgreSQL.
- Open the Terminal application on your Mac.
- Paste the following command to install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Follow the on-screen instructions to complete the installation.

Step 2: Install PostgreSQL
After installing Homebrew, use the following command to install PostgreSQL:
brew install postgresql
Wait for the installation to complete. PostgreSQL will be installed along with its dependencies.


Step 3: Start PostgreSQL Service
Once installed, you need to start the PostgreSQL service.
brew services start postgresql
This command ensures that PostgreSQL runs in the background and starts automatically after a system reboot.

Step 4: Verify Installation
- To confirm PostgreSQL is installed and running, use the following command:
psql --version
If installed correctly, this will display the version of PostgreSQL.

Step 5: Access PostgreSQL
You can now use the psql
command-line tool to access PostgreSQL:
psql postgres
This will connect you to the default PostgreSQL database.

Conclusion
By following these steps, you have successfully installed PostgreSQL on your Mac. You can now start using PostgreSQL to manage your databases.