Download and install PostgreSQL

Installing PostgreSQL is a pretty straightforward process. We can find the installer package and detailed instructions to install PostgreSQL from the EnterpriseDB site.

Steps for installing PostgreSQL

For Windows

If we want to use PostgreSQL on our Windows machine, there are a few steps we need to take to get it up and running.

  1. Go to the PostgreSQL website and download the latest Windows installer.

  2. Once it’s downloaded, run it and follow the instructions to complete the installation process.

  3. Next, we’ll be prompted to provide the following configuration details:

    1. Select the components to be installed. The components of the PostgreSQL database that we can install using this wizard include:

      1. PostgreSQL server: This is the main PostgreSQL process that runs in the background and manages all the data on our database.

      2. The pgAdmin4 tool: This is the main management tool for PostgreSQL, allowing us to easily create and manage our databases.

      3. Command-line tools: These provide a powerful way to interact with our database, allowing us to perform various operations such as querying data and adding new records.

      4. Stack builder: This tool allows us to install additional extensions, such as PostGIS spatial extensions and modules for PostgreSQL, such as language packs and database drivers, enabling us to customize our database to meet our specific needs.

    2. Next, we specify the data directory. By default, the data directory is located at C:\Program Files\PostgreSQL\<version>\data. The <version> refers to the major release version of the PostgreSQL database. For example, it will be 14 for Postgres 14.1.24, and it contains all of the data files for our PostgreSQL database.

    3. Next, we need to specify the port on which we want to run PostgreSQL. The default port is 5432, but we can change it, if necessary.

    4. Then, we need to select a locale for the database.

    5. When prompted, enter a password for the database superuser (postgres). It’s important to choose a strong and secure password that we won’t easily forget.

  4. Click “Finish” to complete the installation.

In Windows, by default, PostgreSQL is installed in the directory C:\Program Files\PostgreSQL.

For macOS

PostgreSQL installation on macOS is very similar to Windows. We need to choose the components to install, set the superuser password for the database password, specify a data directory for storing our data files, and choose a port on which to run PostgreSQL, as described above.

  1. To install, go to the PostgreSQL website and download the latest MacOS installer.

  2. Double-click the installer to open it and follow the prompts to complete the setup process.

  3. As in the case of Windows, we need to choose the components to install, set the superuser password for the database password, specify a data directory for storing our data files, and choose a port on which to run PostgreSQL as described above.

  4. Click “Next” on the “Ready to Install” page of the installation wizard to complete the installation.

By default, PostgreSQL is installed in the following directory path on our macOS: /Library/PostgreSQL/<version> directory.

Get hands-on with 1200+ tech skills courses.