How to install PostgreSQL
on macOS: 2 simple ways

Without a doubt, Windows is the key platform for the majority of database development and management solutions, and those related to PostgreSQL are no exception here. But we should never forget about macOS, the second most popular operating system.

This is where we'd like to show you how to install PostgreSQL on a Mac, create databases, and start managing them using a specialized IDE called dbForge Studio for PostgreSQL.


TL;DR

PostgreSQL can be installed on macOS using either a traditional installer or the Homebrew package manager. After installation, you can manage PostgreSQL databases through the terminal or with a GUI client like dbForge Studio for PostgreSQL, which simplifies tasks like creating databases, configuring users, and importing/exporting data. dbForge Studio also offers advanced tools for database management, making PostgreSQL easier to handle on macOS.

Why install PostgreSQL on macOS?

PostgreSQL is one of the most trusted open-source databases, valued for its stability, scalability, and support for both SQL and JSON queries. It powers everything from small applications to enterprise-grade systems, thanks to features like concurrency control, recovery options, and strong performance tuning.

When it comes to running PostgreSQL locally, macOS is a well-suited platform with its UNIX foundation and native tools like Terminal and Homebrew. It offers a straightforward way to install, configure, and manage PostgreSQL directly on your machine, making it easy to prototype applications, test features, or practice database administration without needing a separate server setup.

How to download and install PostgreSQL –
a step-by-step guide

There are two ways to install PostgreSQL on your Mac. The first one is just your usual way of installing a program, when you download an installer file, open it, and follow the wizard's instructions. The second way is installing PostgreSQL on your Mac via Homebrew, a specialized package manager. The guide below will thoroughly cover both of these ways.

Download the PostgreSQL installer and install it on macOS

1. Download the PostgreSQL installer for macOS

Your first step is to download the PostgreSQL installer for macOS. Once you are on the Download PostgreSQL page, select the preferred version.

Download the PostgreSQL installer for macOS

2. Open the downloaded .dmg file

Open the downloaded .dmg file. Double-click the installer file within and click Open. If your Mac is locked with a password, you will be prompted to enter it.

Open the downloaded file

3. Open the installation wizard

The wizard opens. Click Next.

Open the installation wizard

4. Specify the installation directory

Specify the directory on your Mac where PostgreSQL will be installed and click Next.

Specify the installation directory

5. Select the required components

Keep the components you want to install selected and click Next.

Select the required components

6. Specify the data directory

Specify the directory where your data will be stored and click Next.

Specify the data directory

7. Provide a password

Provide a new password for the database superuser. Later on, you will use it to connect to PostgreSQL. After that, click Next.

Provide a password

8. Specify the port

Change the default port, if necessary, and click Next.

Specify the port

9. Select the locale

Select the locale that will be used by PostgreSQL. By default, it will use the locale of your current operating system.

Select the locale

10. Review the pre-installation summary

Review the pre-installation summary. Once you make sure everything is correct, click Next.

Review the pre-installation summary

11. Launch the installation

Now PostgreSQL is ready for installation. Click Next.

Launch the installation

12. Let the installation proceed

Give the installer a few minutes to conduct the installation.

Let the installation proceed

13. Complete the installation

Once the installation is complete, you will receive a notification. If you have previously selected Stack Builder to be installed, you will be prompted to launch it at exit. Afterwards, click Finish to exit the wizard. You have installed PostgreSQL on your Mac.

Complete the installation

Use Homebrew to install PostgreSQL on macOS

The alternative way to install PostgreSQL on your Mac is to use the Homebrew package manager.

1. Install Homebrew on your Mac

Before installing PostgreSQL, you'll need Homebrew, the de-facto package manager for macOS. Homebrew simplifies software installation, manages dependencies automatically, and ensures you're working with up-to-date versions of required tools.

Follow these steps to install it:

1. Open terminal: Launch it from Applications, Utilities or via Spotlight search.

2. Run the installation script: This command downloads and installs Homebrew on your system.

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

3. Authenticate: Enter your macOS password when prompted. Characters will not appear as you type.

4. Update package definitions: Refresh Homebrew to ensure the latest versions of formulas are available.

brew update

5. Verify the installation: Confirm success by checking the installed version.

 brew --version

If the command returns a version number, Homebrew is installed correctly and ready to use.

2. Install PostgreSQL via Homebrew

Next, you start installing PostgreSQL by running the following command:

brew install postgresql

The installation will commence. If something doesn't run smoothly, Terminal will prompt you for additional actions.

Then give it a little time to be completed. What is great about this method is that Homebrew will automatically manage the dependencies required by PostgreSQL, and you won't have to install anything separately.

Once the installation is completed, you will see a message similar to the following:

Install PostgreSQL via Homebrew

Complete the installation

After installing PostgreSQL, it's important to verify that the setup is successful and that the service is ready to use. Follow the steps below to confirm.

Verify the installation: Open Terminal and check the version:

psql --version

If PostgreSQL is installed successfully, this command will return the version number (e.g., psql (PostgreSQL) 16.x).

Confirm the service is running: Depending on how you installed PostgreSQL, the server may not start automatically. For Homebrew installations, check the status.

brew services list

Start the service if needed.

brew services start postgresql

At this stage, your Terminal should display the output confirming that PostgreSQL was installed and initialized correctly.

Test connectivity with a client: You can now connect using either command-line tools or a GUI.

  • pgAdmin is included in the installer package and provides a browser-based interface for database management.
  • dbForge Studio for PostgreSQL offers a professional IDE with advanced tools for development, administration, and data import/export.

With these checks complete, your PostgreSQL environment is ready for use. You can now move on to creating your first database and configuring users.

First launch and connection to PostgreSQL

Start PostgreSQL via Terminal

Once PostgreSQL is installed via Homebrew, it must be started manually for first use. By default, the server is installed but not running – it won't accept connections until the service is enabled. Homebrew manages PostgreSQL as a background service; you can start, stop, or restart it as needed.

1. Start the PostgreSQL service

brew services start postgresql

This command launches PostgreSQL and ensures it starts automatically whenever your Mac boots. The result will look similar to the screenshot below:

Start PostgreSQL via Terminal

2. Verify that PostgreSQL is running

 pg_isready

This utility checks the server's status and will return a message indicating whether the server is accepting connections.

3. Connect directly to confirm (optional)

 psql -U postgres

If successful, it opens the psql interactive shell as the default superuser, confirming the database is active and ready to use.

Note
You can stop PostgreSQL using the brew services stop postgresql command.

Create a root user

By default, PostgreSQL creates a single administrative account (postgres). However, the best practice is to create your own superuser account rather than relying solely on the default. A superuser has full control over the database cluster, including the ability to create new databases, manage roles, assign privileges, and perform maintenance tasks.

This separation also improves security and makes auditing easier, since activity can be tied to a specific account instead of the global postgres user.

To begin, connect to PostgreSQL using the default account:

psql postgres

The result will be as follows:

Create a root user

Once inside the PostgreSQL prompt, you can create a new superuser.

CREATE USER admin WITH PASSWORD 'yourpassword' SUPERUSER;

You can also fine-tune the user's role:

  • CREATEDB: allows the user to create databases
  • CREATEROLE: allows the user to create and manage other roles
  • LOGIN: enables login access

Example with multiple options

 CREATE USER dev_admin WITH PASSWORD 'mypassword' CREATEDB CREATEROLE LOGIN;

This flexibility lets you design accounts that fit your project needs while keeping administrative tasks under control.

Need a reliable solution to manage your PostgreSQL databases?

Get the most comprehensive PostgreSQL IDE - dbForge Studio for PostgreSQL

How to manage PostgreSQL databases using a GUI client

But what if we suggest an alternative to Terminal that will make it all far easier and way faster? We believe that what you really need at this step is a multifunctional PostgreSQL GUI client that will help you create and manage databases. And we've got one for you! It's called dbForge Studio for PostgreSQL, and it delivers multiple tools for the development and management of your databases.

Although dbForge Studio is a classic Windows application, you can run it on macOS using a compatibility solution called CrossOver. You will find a detailed installation guide and a handy video tutorial on the Installation on Linux & macOS: Overview page of our documentation.

1. How to connect to a PostgreSQL database

Before you can create or manage data, you need to establish a reliable connection to your PostgreSQL server. Proper connection setup ensures that authentication, host information, and access rights are correctly configured; without it, queries and administration tasks won't succeed.

To connect to a PostgreSQL database using dbForge Studio for PostgreSQL, launch it and click New Connection on the Database menu.

Create a new connection in dbForge Studio for PostgreSQL

In the Database Connection Properties window that opens, specify the connection properties:

  • Enter host and port: Use localhost for local installations or the server's IP/domain for remote access. PostgreSQL defaults to port 5432 unless configured otherwise.
  • Provide authentication details: Enter the username (commonly postgres) and the password you set during installation.
  • Select the database: Choose the target database from the list, or leave this field blank to connect to the default database.
  • Test the connection: Click Test Connection to confirm that the credentials and server details are correct.

Provide connection details and test connection settings

Once validation passes, click Connect. dbForge Studio for PostgreSQL will establish the session and display your database in Database Explorer, and you can begin running SQL queries, managing schemas, or importing data.

Note
Besides PostgreSQL, you can establish a connection with quite a few compatible cloud databases, storage services, and search engines.

2. How to create and configure users in PostgreSQL

Creating a new user is just as easy. Click New SQL and enter the CREATE ROLE <username>; command. Run it with the Execute button. Once the Studio finishes the process, you will see the following notification: Query executed successfully.

How to create and configure users in PostgreSQL

Let us show you a few options to diversify this command. First, we create a user with no password:

CREATE USER <username>;

Create a user with a password:

CREATE USER <username> WITH PASSWORD '<password>';

This is how you create a user with a password that is valid until a specified date:

CREATE USER <username> WITH PASSWORD '<password>' VALID UNTIL 'YYYY-MM-DD';

And this is how you create an account where the user can create databases:

CREATE USER <username> WITH PASSWORD '<password>' CREATEDB;

Similarly, you can configure users with the ALTER USER command. For instance, you can provide a user with the ability to create new users and databases:

ALTER USER <username> CREATEUSER CREATEDB;

Finally, this is how you delete a user:

DROP USER <username>

3. How to create and drop a PostgreSQL database

To create a new database, first, click New SQL.

Open a new SQL document for a PostgreSQL database

In a new SQL document, enter the command, replacing my_database with your preferred name:

CREATE DATABASE <database name>;
Create a test PostgreSQL database

In Database Explorer, click the Refresh button. Your new database will appear under your connection.

View a new PostgreSQL database in dbForge Studio

To drop the database, execute the following command:

 DROP DATABASE my_database;

The specified database will be permanently removed.

4. How to export and import PostgreSQL data

Now let's see how to import PostgreSQL data into your new database. You have a whopping 10 formats to choose from, including TXT, XLS, XLSX, Google Sheets, MDB, XML, JSON, CSV, ODBC, and DBF. Go to the Database menu and click Import Data to open the wizard.

Open the Data Import wizard

After you select a format, follow the wizard to configure the import settings. Note that the wizard tabs and available settings may vary depending on the format. After you configure everything as required, click Import, and wait a while for the process to be completed. Note that you can save your import settings as a template using the Save Template button.

Save the data import settings as a template for reuse

Similarly, on the Database menu, click Export Data to get the export wizard ready. Here, you have even more formats to choose from, additionally including HTML, RTF, PDF, and SQL.

Open the Data Export wixard
Download dbForge Studio for PostgreSQL
for a free 30-day trial today!
Now that you know all about installing and managing PostgreSQL databases on your Mac, we can only invite you one more time to download a FREE 30-day trial version of dbForge Studio for PostgreSQL and see it in action. We believe you will find its capabilities invaluable in your daily work.

How to uninstall PostgreSQL from macOS

1. Initiate the uninstallation in Terminal

There are several reasons you might need to uninstall PostgreSQL: for example, upgrading to a newer major version, removing a corrupted installation, or preparing your system for a clean reconfiguration.

When installed via the official macOS installer, PostgreSQL includes an uninstaller utility that launches through an interactive prompt. Let us see how to use it. To begin the process, open Terminal and run the following command (adjust the path if your version differs).

open /Library/PostgreSQL/15/uninstall-postgresql.app

You will be prompted for administrator privileges, since the uninstaller must remove binaries, libraries, and data directories from protected system paths. Once authenticated, the wizard will guide you step by step through the removal process.

Initiate the uninstallation in Terminal

2. Let the uninstallation proceed

After confirming your choice, the wizard begins removing PostgreSQL and its associated files. This step is automatic and requires no further input. You will see a progress window indicating which components are being deleted.

Let the uninstallation proceed

3. Uninstall PostgreSQL from macOS via Homebrew

If you installed PostgreSQL through Homebrew, you can also remove it using Homebrew commands. Before uninstalling, it is best practice to stop the PostgreSQL service to avoid leaving background processes running.

Stop the PostgreSQL service

brew services stop postgresql

Uninstall PostgreSQL

brew uninstall postgresql

After running this command, Homebrew will remove PostgreSQL and its related files. The output should look similar to the screenshot below.

Uninstall PostgreSQL from macOS via Homebrew

These commands will remove PostgreSQL while preserving your overall Homebrew setup. If you need to reinstall a different version later, Homebrew will handle the dependencies automatically.