Ad – 728×90
🗄️ Introduction

SQL Installation & Setup – MySQL, PostgreSQL & SQLite

You have learned what SQL is and why it matters — now it is time to get a database running on your machine. This lesson covers three options: SQLite (the best choice for learning — no server needed), MySQL (the most popular web database), and PostgreSQL (the most feature-rich open-source database). If you do not want to install anything yet, the lesson also covers zero-install online options so you can start writing SQL in your browser right now.

⏱️ 20 min read 🎯 Beginner 📅 Updated 2026

Choosing Your Database

All three databases teach the same core SQL skills — the choice mainly affects the tooling experience during setup:

DatabaseSetup ComplexityBest ForFree?
SQLite Minimal — file-based, no server Learning SQL, mobile apps, embedded use, Python dev Yes (public domain)
MySQL Medium — requires a running server process Web applications, LAMP/LEMP stack, WordPress Yes (GPL edition)
PostgreSQL Medium — requires a running server process Complex queries, full ANSI compliance, production apps Yes (MIT-style)
💡
Recommendation for beginners: start with SQLite

SQLite requires no installation, no server process, no password, and no configuration. A database is just a single .db file. Open DB Browser for SQLite, create a database, and you are querying in under 5 minutes. All the SQL you learn on SQLite transfers directly to MySQL and PostgreSQL.

SQLite Setup

SQLite is already built into Python, Android, iOS, and most browsers. The easiest way to use it is through DB Browser for SQLite — a free, open-source GUI that works on Windows, macOS, and Linux.

Option A: DB Browser for SQLite (Recommended GUI)

  1. Download from sqlitebrowser.org — choose the installer for your OS.
  2. Install and open the app.
  3. Click New Database, name your file (e.g. learning.db), and save it anywhere.
  4. Click Execute SQL tab — type any SQL query and press F5 to run it.

Option B: Python's Built-in sqlite3 (No Download Needed)

If you have Python installed, sqlite3 is available with no extra installation:

Python
import sqlite3

# Creates learning.db if it doesn't exist
conn = sqlite3.connect("learning.db")
cursor = conn.cursor()

cursor.execute("""
    CREATE TABLE IF NOT EXISTS employees (
        id         INTEGER PRIMARY KEY AUTOINCREMENT,
        first_name TEXT NOT NULL,
        salary     REAL
    )
""")

cursor.execute("INSERT INTO employees (first_name, salary) VALUES ('Alice', 85000)")
conn.commit()

for row in cursor.execute("SELECT * FROM employees"):
    print(row)

conn.close()

Option C: SQLite Command-Line Shell

Shell
# macOS (already installed) or Linux
sqlite3 learning.db

# Windows: download sqlite-tools from sqlite.org/download.html
# Unzip and run sqlite3.exe

# Inside the SQLite shell:
sqlite> CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT);
sqlite> INSERT INTO test VALUES (1, 'Hello SQL');
sqlite> SELECT * FROM test;
sqlite> .quit

MySQL Setup

MySQL requires a server process running in the background. Once installed, you connect to it with a client — either the command-line mysql tool or MySQL Workbench (GUI).

Shell – macOS (Homebrew)
# Install MySQL
brew install mysql

# Start the MySQL service
brew services start mysql

# Connect (no password on fresh install)
mysql -u root

# Set a root password (recommended)
ALTER USER 'root'@'localhost' IDENTIFIED BY 'your_password';
FLUSH PRIVILEGES;
Shell – Ubuntu / Debian
# Install MySQL server
sudo apt update
sudo apt install mysql-server

# Start the service
sudo systemctl start mysql
sudo systemctl enable mysql   # auto-start on boot

# Run the security setup wizard (sets root password, removes test DB)
sudo mysql_secure_installation

# Connect
mysql -u root -p
Shell – Windows
# Download MySQL Installer from dev.mysql.com/downloads/installer/
# Run the installer, choose "Developer Default" setup type
# Follow the wizard — it installs MySQL Server + MySQL Workbench + Shell

# After installation, connect via Command Prompt:
mysql -u root -p
Ad – 336×280

PostgreSQL Setup

PostgreSQL (often called "Postgres") is the most feature-complete open-source SQL database. It is the recommended choice for new production applications in 2026.

Shell – macOS (Homebrew)
# Install PostgreSQL 16
brew install postgresql@16

# Add to PATH (add this to ~/.zshrc or ~/.bash_profile)
export PATH="/opt/homebrew/opt/postgresql@16/bin:$PATH"

# Start the service
brew services start postgresql@16

# Connect to the default postgres database
psql -U postgres

# Or create a database for learning
createdb learning_sql
psql learning_sql
Shell – Ubuntu / Debian
# Install PostgreSQL
sudo apt update
sudo apt install postgresql postgresql-contrib

# Start the service
sudo systemctl start postgresql
sudo systemctl enable postgresql

# Connect as the postgres superuser
sudo -u postgres psql

# Inside psql — create a database
CREATE DATABASE learning_sql;
\c learning_sql   -- connect to it
\l                -- list all databases
\dt               -- list tables in current DB
\q                -- quit

GUI Tools

Command-line clients are powerful, but most developers prefer a GUI for day-to-day SQL work. Here are the best free options:

ToolDatabasesPlatformBest For
DB Browser for SQLiteSQLite onlyWin / Mac / LinuxLearning with SQLite — simple and lightweight
MySQL WorkbenchMySQL / MariaDBWin / Mac / LinuxMySQL development — includes schema designer, query profiler
pgAdmin 4PostgreSQLWin / Mac / LinuxPostgreSQL administration — feature-rich web-based GUI
DBeaverAll databasesWin / Mac / LinuxMulti-database work — one tool for everything
VS Code SQLToolsMySQL, PostgreSQL, SQLite, moreWin / Mac / LinuxStaying in VS Code — write SQL alongside your code

DBeaver is an excellent all-in-one choice: it connects to MySQL, PostgreSQL, SQLite, SQL Server, Oracle, and dozens more databases through a single application. The community edition is free and has everything you need for learning and development.

Online Zero-Install Options

If you want to start practising SQL immediately without installing anything, these browser-based tools are excellent:

  • sqliteonline.com — SQLite in the browser. Upload an existing .db file or start fresh. No account needed.
  • db-fiddle.com — Supports MySQL, PostgreSQL, and SQLite. Great for creating shareable query examples.
  • sqlfiddle.com — Similar to db-fiddle. Good for testing cross-database compatibility.
  • OneCompiler SQL — Instant SQL execution with sample databases included.
ℹ️
This course uses standard ANSI SQL

All examples in this course use standard ANSI SQL syntax that runs unmodified in MySQL, PostgreSQL, and SQLite. Where a meaningful dialect difference exists — such as auto-increment syntax, string functions, or date handling — a highlighted note will point it out. You will not miss anything important by using any of the three databases.

📋 Summary

  • SQLite — file-based, zero server, built into Python. Best for learning. Use DB Browser for SQLite as the GUI.
  • MySQL — most popular web database. Install via Homebrew, apt, or the Windows installer. Connect with mysql -u root -p.
  • PostgreSQL — most feature-rich open-source DB. Install via Homebrew or apt. Connect with psql -U postgres.
  • GUI tools: DB Browser (SQLite), MySQL Workbench (MySQL), pgAdmin (PostgreSQL), DBeaver (all databases), VS Code SQLTools.
  • Zero-install options: sqliteonline.com and db-fiddle.com — start querying in your browser right now.
  • All examples in this course use standard ANSI SQL — valid across all three databases.

FAQ

Which database should I choose to learn SQL? +

For learning SQL, SQLite with DB Browser is the simplest and fastest to set up. There is no server process, no password, no network configuration — just open the GUI and start writing queries. The core SQL you learn (SELECT, WHERE, JOIN, GROUP BY, etc.) is identical across SQLite, MySQL, and PostgreSQL. Once you are comfortable with SQL basics, MySQL and PostgreSQL are both excellent for building real applications.

Is PostgreSQL better than MySQL? +

Both are excellent, but PostgreSQL is generally considered the stronger choice for new projects in 2026. PostgreSQL has better ANSI SQL compliance, more advanced features (window functions, CTEs, JSON operators, array types), stricter data integrity defaults, and a stronger open-source governance model. MySQL has a larger hosting ecosystem (nearly every web host supports it) and is slightly simpler to get started with. If you are building a new application from scratch, PostgreSQL is the modern default recommendation. MySQL is a solid choice if you are working in a WordPress/LAMP environment.

Can I use VS Code to write SQL queries? +

Yes. The SQLTools extension (free, from the VS Code Marketplace) adds SQL syntax highlighting, query execution, and database connections directly inside VS Code. You can connect to SQLite, MySQL, PostgreSQL, and many other databases, run queries with Ctrl+Enter, and see results in a table right in the editor. If you already use VS Code for other languages, SQLTools lets you avoid switching to a separate GUI tool.

Is SQLite suitable for production applications? +

Yes, for certain use cases. SQLite is used in production by millions of apps, including browsers (Chrome, Firefox store their databases in SQLite), mobile apps (all iOS and Android apps use SQLite internally), and embedded systems. It is not suitable for high-concurrency web applications with many simultaneous writers — for that, use PostgreSQL or MySQL. But for read-heavy applications, CLI tools, mobile apps, and applications with a single writer, SQLite in production is perfectly valid and used extensively.