SQLite is a serverless, file-based relational database engine that requires no installation of a separate server process and no ongoing administration. It stores an entire database — tables, indexes, and data — in a single cross-platform file, making it ideal for development environments, embedded applications, configuration stores, and lightweight production workloads that do not need concurrent writes from multiple processes. This tutorial covers installing SQLite on RHEL 8, using the interactive shell, running queries from scripts, installing the graphical browser, and configuring essential PRAGMA settings for reliability and performance.

Prerequisites

  • RHEL 8 server or workstation with sudo access
  • An active internet connection for package downloads
  • Basic familiarity with the Linux command line
  • EPEL repository enabled if you plan to install SQLite Browser (the GUI tool)

Step 1 — Install SQLite with dnf

SQLite is available in the default RHEL 8 AppStream repository. Install the sqlite package, which provides the shared library and the sqlite3 command-line shell.

sudo dnf install -y sqlite

# Verify the installation
sqlite3 --version

The output will show the SQLite version, build date, and source ID — for example 3.34.1 2021-01-20 .... The sqlite3 command is now available system-wide for all users.

Step 2 — Basic sqlite3 Interactive Shell Usage

Launch the interactive shell by passing a file path as the argument. If the file does not exist, SQLite creates it when the first write occurs. The shell accepts both SQL statements and dot-commands that control the shell itself.

# Open (or create) a database file
sqlite3 /home/myuser/myapp.db

-- Inside the sqlite3 shell:

-- Create a table
CREATE TABLE IF NOT EXISTS users (
    id      INTEGER PRIMARY KEY AUTOINCREMENT,
    name    TEXT    NOT NULL,
    email   TEXT    UNIQUE NOT NULL,
    created TEXT    DEFAULT (datetime('now'))
);

-- Insert sample rows
INSERT INTO users (name, email) VALUES ('Alice', '[email protected]');
INSERT INTO users (name, email) VALUES ('Bob',   '[email protected]');

-- Query all rows
SELECT * FROM users;

-- List all tables
.tables

-- Show the schema for a table
.schema users

-- Exit the shell
.quit

Step 3 — Run SQLite Queries from Shell Scripts

Pass a database file path and a quoted SQL statement directly to sqlite3 on the command line to execute queries non-interactively. This is particularly useful in cron jobs, deploy scripts, and monitoring pipelines. Use the -separator and -csv flags to control output format.

# Run a single query inline
sqlite3 /home/myuser/myapp.db "SELECT COUNT(*) FROM users;"

# Output as CSV with headers
sqlite3 -header -csv /home/myuser/myapp.db "SELECT id, name, email FROM users;"

# Execute a multi-statement SQL file
sqlite3 /home/myuser/myapp.db < /opt/scripts/seed_data.sql

# Use in a bash script
USER_COUNT=$(sqlite3 /home/myuser/myapp.db "SELECT COUNT(*) FROM users;")
echo "Total users: $USER_COUNT"

Step 4 — Install DB Browser for SQLite (GUI) from EPEL

DB Browser for SQLite (sqlitebrowser) provides a graphical interface for browsing table structures, running queries with syntax highlighting, and importing CSV data. It is available in the Extra Packages for Enterprise Linux (EPEL) repository.

# Enable the EPEL repository if not already enabled
sudo dnf install -y epel-release

# Install DB Browser for SQLite
sudo dnf install -y sqlitebrowser

# Launch the GUI (requires a desktop session)
sqlitebrowser &

If you are working on a headless server, use X11 forwarding (ssh -X) or a remote desktop session to display the GUI on your local machine.

Step 5 — Configure Essential PRAGMA Statements

SQLite PRAGMA statements are special commands that read or set database engine options. The two most important for production use are journal_mode and foreign_keys. WAL (Write-Ahead Logging) journal mode significantly improves concurrent read performance and reduces write contention. Foreign key enforcement is disabled by default and must be enabled per connection.

sqlite3 /home/myuser/myapp.db <<'SQL'

-- Enable WAL mode for better concurrent read performance
-- This is persistent and only needs to be set once per database file
PRAGMA journal_mode = WAL;

-- Enable foreign key constraint enforcement (must be set each connection)
PRAGMA foreign_keys = ON;

-- Check current settings
PRAGMA journal_mode;
PRAGMA foreign_keys;

-- Additional useful PRAGMAs:
-- Set cache size to 10 000 pages (~40 MB with default 4 KB pages)
PRAGMA cache_size = 10000;

-- Synchronise less aggressively for write speed (acceptable with WAL)
PRAGMA synchronous = NORMAL;
SQL

Because foreign_keys resets to OFF at the start of every new connection, add it to your application’s connection initialisation code or use a connection event hook in your framework.

Step 6 — SQLite vs MySQL: Choosing the Right Tool

SQLite is the right choice when the application is the only writer, portability matters, or a full server process is impractical. MySQL or PostgreSQL are better suited when you need high-concurrency writes, network access from multiple clients, row-level locking, replication, or built-in user authentication. Use the comparison below to guide your decision.

# SQLite strengths
# - Zero configuration; no server process to manage
# - Single file backup: cp myapp.db myapp.db.bak
# - Excellent for local development, embedded devices, desktop apps
# - Read concurrency is excellent with WAL mode

# MySQL / PostgreSQL strengths
# - High-concurrency write workloads (many simultaneous writers)
# - Network-accessible from multiple application servers
# - Advanced features: stored procedures, partitioning, full-text search
# - Built-in replication and high-availability options

Conclusion

You have installed SQLite on RHEL 8 using dnf, explored the interactive shell for creating tables and running queries, executed queries non-interactively from shell scripts, installed the DB Browser graphical tool from EPEL, and configured WAL journal mode and foreign key enforcement through PRAGMA statements. SQLite requires no server process, making it a practical choice for development environments, single-writer applications, and embedded data storage where the simplicity of a file-based database outweighs the need for a full server stack.

Next steps: How to Secure MySQL on RHEL 8, How to Install and Configure PostgreSQL on RHEL 8, and How to Back Up PostgreSQL with pg_dump and pg_basebackup on RHEL 8.