FastAPI - Beginner to Pro / Large Production Database Setup

PostgreSQL Mac Installation

🐘 Installing PostgreSQL on macOS

PostgreSQL is a powerful open-source relational database used in many production systems. It works well with frameworks like Django, FastAPI, Node.js, and Spring Boot.


πŸ’» Install PostgreSQL Using Postgres.app

πŸ“¦ Step 1: Install Postgres.app

πŸ”— Download

πŸ“₯ Install

  1. Open the downloaded .dmg file

  2. Drag Postgres.app into the Applications folder

  3. Open Postgres.app

  4. Click Initialize


↔️ Step 2: Configure Installation

  • Open Terminal

  • Paste the below code and click ENTER

sudo mkdir -p /etc/paths.d &&
echo /Applications/Postgres.app/Contents/Versions/latest/bin | sudo tee /etc/paths.d/postgresapp

🧰 Step 3: Install pgAdmin

πŸ”— Download

  • Go to: https://www.pgadmin.org/download/pgadmin-4-macos/

  • Select Version

  • Now Download from the Files Section

    πŸ‘‰ If you have a newer Mac (Apple Silicon)

    • MacBook M1 / M2 / M3 / M4

      βœ… Download: pgadminX-X.XX-arm64.dmg

    πŸ‘‰ If you have an older Intel Mac

    • Intel i5 / i7 / i9

      βœ… Download: pgadminX-X.XX-x64.dmg

πŸ“₯ Install

  1. Download .dmg

  2. Drag pgAdmin 4 to Applications

  3. Open pgAdmin


πŸ” Step 4: Connect pgAdmin to Postgres

🧩 First-Time Setup

  • pgAdmin will ask for a master password β†’ set anything (this is for pgAdmin security)


⚑ Useful PostgreSQL Commands

Command

Description

psql postgres

Connect to database

\\l

List databases

\\c dbname

Connect to database

\\dt

List tables

\\q

Quit psql