How to Download, Install and run PostgreSQL on Mac and Windows

To download, install, and run PostgreSQL on your local machine, you can follow these steps:

1. Download PostgreSQL:

  • Visit the official PostgreSQL website at https://www.postgresql.org/download/.
  • Choose the appropriate version for your operating system (Windows, macOS, or Linux).
  • Download the installer package for your system.

2. Install PostgreSQL:

  • Run the downloaded installer package.
  • Follow the installation wizard instructions.
  • During the installation, you will be prompted to select various options. You can generally accept the default settings unless you have specific requirements.
  • Make sure to remember the password you set for the database superuser (usually named “postgres”) during the installation process.

3. Configure PostgreSQL:

  • After the installation completes, you may need to configure some additional settings.
  • Open the PostgreSQL configuration file. The location of this file depends on your operating system and PostgreSQL version.
    • For Windows: C:\Program Files\PostgreSQL\<version>\data\postgresql.conf
    • For macOS and Linux: /etc/postgresql/<version>/main/postgresql.conf
  • In the configuration file, you can modify various settings such as the listen address, port, etc. You may want to review and adjust these settings according to your needs. Save the changes.

4. Start the PostgreSQL Server:

  • Depending on your operating system, there are different ways to start the PostgreSQL server:
    • For Windows:
      • Open the Start menu and search for “pgAdmin” or “SQL Shell” (psql). Launch either of these applications to start the server.
    • For macOS and Linux:
      • Open a terminal window.
      • Use the following command to start the PostgreSQL service:

        sudo service postgresql start
        
      • You may need to provide your password to authorize the command.

5. Verify the PostgreSQL Installation:

  • Open a terminal or command prompt window.
  • Use the following command to connect to the PostgreSQL server:
    psql -U postgres
    
    • If you set a different username during installation, replace “postgres” with your chosen username.
  • You will be prompted for the password you set during installation.
  • If the connection is successful, you will see a PostgreSQL prompt.

Congratulations! You have successfully downloaded, installed, and started the PostgreSQL server on your local machine. You can now start creating databases and using PostgreSQL for your projects.