DeveloperBreeze

How to install PostgreSQL

1. Install PostgreSQL on macOS

Using Homebrew:

  1. Update Homebrew:
   brew update
  1. Install PostgreSQL:
   brew install postgresql
  1. Start PostgreSQL:
   brew services start postgresql
  1. Verify Installation:
   psql --version

To Connect to PostgreSQL:

   psql postgres

2. Install PostgreSQL on Ubuntu/Debian

  1. Update Package List:
   sudo apt update
  1. Install PostgreSQL:
   sudo apt install postgresql postgresql-contrib
  1. Check PostgreSQL Service:

PostgreSQL starts automatically; to check the status:

   sudo systemctl status postgresql
  1. Verify Installation:
   psql --version

To Connect to PostgreSQL:

   sudo -u postgres psql

3. Install PostgreSQL on Windows

  1. Download Installer:

Go to the PostgreSQL website and download the installer.

  1. Run the Installer:
  • Launch the installer and follow the instructions.
  • Select Command Line Tools during the installation process.
  1. Verify Installation:

After installation, open a Command Prompt and type:

   psql --version

To Connect to PostgreSQL:

  • Open the psql command line interface from the Start menu or use:
     psql -U postgres
  • Enter the password you set during installation.

4. Post-Installation Tips

  • Create a Database:
  CREATE DATABASE mydatabase;
  • List Databases:
  \l
  • Connect to a Database:
  \c mydatabase
  • Exit psql:
  \q

This guide should get PostgreSQL up and running on your system!

Related Posts

More content you might like

Tutorial

How to Stop SSH From Timing Out

On your local machine, edit or create:

nano ~/.ssh/config

Aug 21, 2025
Read More
Tutorial

Protect Your Forms Like a Pro: Anti-Spam Techniques That Actually Work

  • Track the time between when the form is rendered and when it’s submitted.
  • Reject if submitted too fast (e.g., < 3 seconds).
document.querySelector('form').dataset.start = Date.now();

Apr 04, 2025
Read More
Tutorial

How To view tables and the number of records in each table in a PostgreSQL database,

  • Right-click on each table, select View/Edit Data > All Rows to see the records.
  • Or, run the above SQL query in the Query Tool to see all tables with row counts.

These methods will help you view tables and get a record count for each in your PostgreSQL database.

Nov 06, 2024
Read More
Tutorial

How to view tables on a PostgreSQL database hosted on Heroku

Run the following command to get your database URL:

   heroku config:get DATABASE_URL -a <your-app-name>

Nov 06, 2024
Read More

Discussion 0

Please sign in to join the discussion.

No comments yet. Be the first to share your thoughts!