How to install PostgreSQL on macOS: Step-by-Step Instructions
If you're using macOS, the steps to install PostgreSQL and set up your environment are slightly different. Here's how to do it: ✅ Step 1: Install PostgreSQL on macOS Option 1: Using Homebrew (Recommended) 1) Install Homebrew (if you haven’t already): /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 2) Install PostgreSQL: brew install postgresql 3) Start PostgreSQL service: brew services start postgresql 4) Initialize the database (if needed): initdb /usr/local/var/postgres 5) Verify installation: psql --version ✅ Step 2: Create a Database and User 1) Enter PostgreSQL CLI: psql postgres 2) Create a new database: CREATE DATABASE mydb; 3) Create a new user (optional): CREATE USER myuser WITH ENCRYPTED PASSWORD 'mypassword'; GRANT ALL PRIVILEGES ON DATABASE mydb TO myuser; Exit with \q. ✅ Step 3: Browse PostgreSQL Data Option 1: Using psql CLI Connect to your database: psql -d mydb -U myuser You can now run SQL queries directly in the terminal. Option 2: Use a GUI Client

If you're using macOS, the steps to install PostgreSQL and set up your environment are slightly different. Here's how to do it:
✅ Step 1: Install PostgreSQL on macOS
Option 1: Using Homebrew (Recommended)
1) Install Homebrew (if you haven’t already):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
2) Install PostgreSQL:
brew install postgresql
3) Start PostgreSQL service:
brew services start postgresql
4) Initialize the database (if needed):
initdb /usr/local/var/postgres
5) Verify installation:
psql --version
✅ Step 2: Create a Database and User
1) Enter PostgreSQL CLI:
psql postgres
2) Create a new database:
CREATE DATABASE mydb;
3) Create a new user (optional):
CREATE USER myuser WITH ENCRYPTED PASSWORD 'mypassword';
GRANT ALL PRIVILEGES ON DATABASE mydb TO myuser;
Exit with \q.
✅ Step 3: Browse PostgreSQL Data
Option 1: Using psql CLI
Connect to your database:
psql -d mydb -U myuser
You can now run SQL queries directly in the terminal.
Option 2: Use a GUI Client