How to Install SQLite on Mac: Built-in sqlite3 and Homebrew (Tested)

macOS ships with SQLite and the sqlite3 shell, so there’s nothing to install to get started. The built-in copy isn’t always the newest version, though, and in this article I’ll walk you through using it and installing a newer one with Homebrew, plus the PATH change Homebrew’s copy needs.

TLDR

  • macOS ships sqlite3 at /usr/bin/sqlite3. Open Terminal and type sqlite3 --version to check it.
  • For a newer version, run brew install sqlite.
  • Homebrew’s SQLite is keg-only, so it isn’t on your PATH. Add /opt/homebrew/opt/sqlite/bin to the front of your PATH to use it.
  • Check which one runs with which -a sqlite3.

What are you installing?

The sqlite3 shell is a command-line program where you type SQL and see results. The SQLite library is the database engine itself, which apps and languages such as Python link in. macOS includes both. Installing SQLite with Homebrew adds a second, newer copy next to Apple’s. It doesn’t replace Apple’s.

Prerequisites

RequirementDetail
macOSAny current version. These steps were tested on macOS 26.6 on Apple silicon
TerminalThe built-in Terminal app, or any other terminal
Homebrew (optional)Only for a newer SQLite. See brew.sh

How to install SQLite on macOS

To show you both options, I ran each command on a Mac with Homebrew’s sqlite formula already installed, using a default macOS PATH.

Option 1: Use the built-in sqlite3

There’s nothing to install. Open Terminal and check where sqlite3 lives and which version it is:

$ which sqlite3
/usr/bin/sqlite3
$ sqlite3 --version | cut -d' ' -f1-2
3.51.0 2025-06-12

The Python that ships with macOS uses the same SQLite version:

$ /usr/bin/python3 -c "import sqlite3; print(sqlite3.sqlite_version)"
3.51.0

Option 2: Install a newer SQLite with Homebrew

This takes two steps: the install, then a PATH change.

#### Step 1: Install the formula

brew install sqlite

On the test Mac it was already installed, so Homebrew printed:

$ HOMEBREW_NO_AUTO_UPDATE=1 brew install sqlite 2>&1 | head -n 1
Warning: sqlite 3.53.4 is already installed and up-to-date.

#### Step 2: Put Homebrew’s sqlite3 first on your PATH

Homebrew installs SQLite as keg-only. It leaves it out of /opt/homebrew/bin because macOS already provides SQLite (Homebrew formula: sqlite). So after the install, sqlite3 still runs Apple’s copy:

$ which -a sqlite3
/usr/bin/sqlite3
$ sqlite3 --version | cut -d' ' -f1
3.51.0

Homebrew’s own caveat says how to change that:

$ brew info sqlite | sed -n '/Caveats/,/zshrc/p'
==> Caveats
sqlite is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

If you need to have sqlite first in your PATH, run:
  echo 'export PATH=/opt/homebrew/opt/sqlite/bin:$PATH' >> ~/.zshrc

With Homebrew’s folder at the front of the PATH, the newer version runs. brew --prefix sqlite prints the folder, which is /opt/homebrew/opt/sqlite on Apple silicon and /usr/local/opt/sqlite on Intel Macs:

$ export PATH="$(brew --prefix sqlite)/bin:$PATH"; which sqlite3; sqlite3 --version | cut -d' ' -f1
/opt/homebrew/opt/sqlite/bin/sqlite3
3.53.4

To make it permanent, add the line from the caveat to ~/.zshrc (zsh is the default shell on macOS), then open a new Terminal window.

Check that it works

Create a database file with one table, then query it. Save the statements as first.sql:

CREATE TABLE page_views (
  id INTEGER PRIMARY KEY,
  page_url TEXT NOT NULL,
  views INTEGER NOT NULL
);
INSERT INTO page_views (page_url, views) VALUES ('/home', 1000), ('/products', 750), ('/about', 500);
$ sqlite3 analytics.db < first.sql
$ sqlite3 -header -column analytics.db "SELECT * FROM page_views WHERE views > 600 ORDER BY views DESC;"
id  page_url   views
--  ---------  -----
1   /home      1000
2   /products  750
$ ls -l analytics.db | awk '{print $5, $NF}'
8192 analytics.db

The whole database is the one analytics.db file. A .dump writes it out as SQL, which is a simple backup you can restore anywhere:

$ sqlite3 analytics.db .dump > analytics_backup.sql
$ sqlite3 restored.db < analytics_backup.sql
$ sqlite3 restored.db "SELECT count(*) FROM page_views;"
3

If you’d rather browse tables in a window, DB Browser for SQLite is a free GUI. Homebrew installs it with brew install --cask db-browser-for-sqlite (not executed here; Homebrew cask).

Troubleshooting

  • sqlite3 --version still shows the old version after brew install sqlite: that’s keg-only working as designed. Add $(brew --prefix sqlite)/bin to the front of your PATH, then open a new Terminal window.
  • Not sure which sqlite3 runs: which -a sqlite3 lists every sqlite3 on your PATH, in order. The first one wins.
  • Python still reports the old SQLite version: Python uses the SQLite library it was built with, not the sqlite3 command. Changing your PATH doesn’t change it.
  • The PATH line didn’t take effect: you edited a different shell’s file. zsh reads ~/.zshrc, and bash reads ~/.bash_profile.

Upgrading or uninstalling

Homebrew’s copy upgrades with brew upgrade sqlite and uninstalls with brew uninstall sqlite. Remove the PATH line from ~/.zshrc afterwards. Don’t try to remove Apple’s /usr/bin/sqlite3. It’s part of macOS and comes back with system updates.

Conclusion

For learning SQL and everyday work, the sqlite3 that ships with macOS is enough. Install Homebrew’s sqlite when you need a newer version, and remember that it only runs once its folder is first on your PATH.

Further reading

Tested with the built-in SQLite 3.51.0 and Homebrew SQLite 3.53.4 on macOS 26.6.2 (Apple silicon), 7 October 2026.