PostgreSQL Tutorial
Data Types
Querying & Filtering Data
Managing Tables
Modifying Data
Conditionals
Control Flow
Transactions & Constraints
Working with JOINS & Schemas
Roles & Permissions
Working with Sets
Subquery & CTEs
User-defined Functions
Important In-Built Functions
PostgreSQL PL/pgSQL
Variables & Constants
Stored Procedures
Working with Triggers
Working with Views & Indexes
Errors & Exception Handling
To install PostgreSQL on macOS, you have a few different options. The most popular ones are:
Here's how you can use each of these methods:
If you haven't installed Homebrew yet, you can do so by following the instructions on their official website or using the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Once you have Homebrew installed, you can install PostgreSQL:
brew update brew install postgresql
After installation, you can start the PostgreSQL service:
brew services start postgresql
Postgres.app is a macOS application that packages and manages a full-featured PostgreSQL installation in a single package.
Postgres.app
to start.This application will run PostgreSQL on its default port (5432) and include other utilities like psql
.
Regardless of the method you choose, you'll probably want to set up the PATH
for command line tools. If you choose the Homebrew option, the path is set up automatically. For Postgres.app, you'll want to add /Applications/Postgres.app/Contents/Versions/latest/bin
to your PATH
.
After installation, you can check if PostgreSQL is running by using the command:
psql -U postgres
This will log you into the PostgreSQL shell. If you encounter no errors, then PostgreSQL is installed and running properly.