SQLite is a self-contained database engine that stores data in a single file, making it ideal for local application storage, development prototyping, and embedded systems. Common use cases include browser history databases, mobile app backends, and configuration storage for desktop applications. By the end of this guide, you will have it installed and verified with a working test database.
However, Fedora Server and minimal installations do not include SQLite by default, though some desktop applications may pull it in as a dependency. This guide covers two installation methods: the Fedora repository for a stable, automatically updated version, and compiling from source for access to the latest features.
Choose Your SQLite Installation Method
Before installing, decide which method suits your needs. Additionally, the table below compares your options:
| Method | Channel | Version | Updates | Best For |
|---|---|---|---|---|
| Fedora Repository (DNF) | Fedora Repos | Stable | Automatic via dnf upgrade | Most users who want hassle-free maintenance |
| Compile from Source | Upstream | Latest | Manual recompilation required | Developers who need cutting-edge features |
Recommendation: Start with the Fedora repository method. DNF handles security updates automatically, and the repository version works reliably for development and most production use cases. Only compile from source if you need a specific feature from a newer SQLite release that hasn’t reached Fedora’s repositories yet.
Method 1: Install SQLite via DNF
Update System Packages
First, ensure your Fedora system is up-to-date before installing SQLite. Updating prevents package conflicts and ensures you get the latest security patches.
To begin, run the following command to update all installed packages:
sudo dnf upgrade --refresh
The --refresh flag forces DNF to check for the latest package versions before upgrading. Enter your password when prompted—you will not see characters as you type, which is normal Linux security behavior.
Install SQLite Package
Next, install SQLite from Fedora’s repository using DNF:
sudo dnf install sqlite
After installation completes, verify the installation by checking the version:
sqlite3 --version
3.47.2 2024-12-07 20:39:59 ...
The version number confirms SQLite is installed. The exact version depends on your Fedora release.
Method 2: Install SQLite from Source
Alternatively, compiling from source gives you the latest SQLite version with all recent bug fixes and features. While this method requires more steps, it remains straightforward—SQLite has minimal dependencies and compiles quickly.
Install Build Dependencies
First, compiling SQLite from source requires a C compiler and build tools. Install the minimal requirements:
sudo dnf install gcc make wget
Notably, SQLite uses the traditional autoconf build system, so make is sufficient.
Download the SQLite Source Archive
Download the latest SQLite autoconf source archive directly from the official download page:
curl -s https://www.sqlite.org/download.html | grep -oP '\d{4}/sqlite-autoconf-\d+\.tar\.gz' | head -1 | xargs -I {} wget https://www.sqlite.org/{}
This command automatically fetches the latest version. Specifically, here is how it works:
curl -s: Silently fetches the SQLite download page HTMLgrep -oP: Extracts the year and tarball filename using regexhead -1: Takes the first match (latest version)wget: Downloads the tarball using the extracted path
SQLite encodes version numbers in filenames: version 3.51.1 becomes
sqlite-autoconf-3510100.tar.gz(major, minor padded to 2 digits, patch padded to 2 digits). If the automated download fails, visit the SQLite download page manually to get the current filename and year directory.
Extract the SQLite Archive
Once the download completes, proceed to extract the source archive:
tar xvfz sqlite-autoconf-*.tar.gz
Navigate to the Source Directory
Following extraction, change to the newly created directory:
cd sqlite-autoconf-*/
Configure the Build
Next, run the configure script to prepare the build. The --prefix=/usr option installs SQLite to the standard system location, matching where DNF would install it:
./configure --prefix=/usr
Upon completion, the output should end with lines similar to:
config.status: creating Makefile config.status: creating sqlite3.pc config.status: executing depfiles commands config.status: executing libtool commands
Compile SQLite
Now, start the build process using make with the -j flag to use multiple CPU cores for faster compilation. First, check your available cores:
nproc
4
Subsequently, compile using that number (or half of it to leave resources free):
make -j$(nproc)
Install the Compiled Binary
After compilation, install SQLite to your system:
sudo make install
The installation copies the sqlite3 binary, libraries, and header files to /usr/. Finally, verify the installation succeeded:
sqlite3 --version
3.51.1 2025-02-18 13:38:58 ...
The version should match the source archive you downloaded.
Test the SQLite Installation
With SQLite installed, now verify it works correctly by creating a test database, inserting data, and running a query. As a result, this confirms both the sqlite3 command-line tool and the database engine function properly.
Create a Test Database and Table
Open the SQLite shell and create a new database file:
sqlite3 testdb.db
This opens the SQLite shell and creates testdb.db in your current directory. Next, create a sample table:
CREATE TABLE employees (id INTEGER PRIMARY KEY, name TEXT, position TEXT);
Press Enter to execute the command; you should see no output if the table is created successfully.
Insert and Query Data
Add sample records to the table using INSERT statements:
INSERT INTO employees (name, position) VALUES ('John Doe', 'Manager');
INSERT INTO employees (name, position) VALUES ('Jane Smith', 'Developer');
INSERT INTO employees (name, position) VALUES ('Alice Johnson', 'Designer');
Each INSERT adds one row. SQLite automatically assigns sequential id values since we defined it as INTEGER PRIMARY KEY.
Now, query the data to verify it was stored correctly:
SELECT * FROM employees;
1|John Doe|Manager 2|Jane Smith|Developer 3|Alice Johnson|Designer
Exit the SQLite shell by typing the dot-command:
.exit
SQLite dot-commands like .exit, .tables, and .schema are internal shell commands, not SQL statements—they do not require a semicolon. The test database file remains in your current directory. Delete it with rm testdb.db when finished testing.
Configure SELinux for Web Applications (Optional)
This section only applies if you are using SQLite with a web server like Apache or Nginx. For command-line usage or desktop applications, skip to the next section.
SELinux (Security-Enhanced Linux) is a security layer that Fedora enables by default. It restricts what programs can access, even if file permissions would normally allow it. For example, if you’re familiar with Windows, think of it as an additional firewall for file access—the web server might have permission to read a file, but SELinux can still block it based on security policy.
Therefore, when a web server needs to read or write SQLite database files, you must label those files with the correct SELinux context. Otherwise, Apache or Nginx will receive “Permission denied” errors even though the file permissions look correct.
Check SELinux Status
To begin, check if SELinux is enabled:
sestatus
SELinux status: enabled Current mode: enforcing
If SELinux is disabled or in permissive mode, no further configuration is needed. If it shows enforcing, continue with the steps below.
Set the SELinux Context
For web server access, SQLite database files need the httpd_sys_rw_content_t context (for read-write access) or httpd_sys_content_t (for read-only). Assuming your database is at /var/www/html/testdb.db:
sudo chcon -t httpd_sys_rw_content_t /var/www/html/testdb.db
Next, verify the context was applied:
ls -lZ /var/www/html/testdb.db
As shown below, the output should show the updated SELinux context for the database file:
-rw-r--r--. root root unconfined_u:object_r:httpd_sys_rw_content_t:s0 /var/www/html/testdb.db
The httpd_sys_rw_content_t context allows the web server to read and write the database file. For more SELinux configuration options, see the guide on managing SELinux on Fedora.
Remove SQLite from Fedora
Remove DNF-Installed SQLite
To remove SQLite installed via DNF:
sudo dnf remove sqlite
Remove Source-Compiled SQLite
If you compiled SQLite from source and still have the source directory, simply run:
cd sqlite-autoconf-*/
sudo make uninstall
However, if you deleted the source directory, manually remove the installed files:
sudo rm -f /usr/bin/sqlite3
sudo rm -f /usr/lib/libsqlite3.*
sudo rm -f /usr/lib/pkgconfig/sqlite3.pc
sudo rm -f /usr/include/sqlite3.h /usr/include/sqlite3ext.h
sudo rm -rf /usr/share/man/man1/sqlite3.1
Removing SQLite does not delete your database files (.db). Back up important databases before deleting them manually.
Troubleshooting Common SQLite Issues
Command Not Found After Source Installation
If you see sqlite3: command not found after compiling from source, the installation location may not be in your PATH. First, check where sqlite3 was installed:
which sqlite3
If this returns nothing, alternatively try running the full path:
/usr/bin/sqlite3 --version
If the binary exists there, open a new terminal or reload your shell:
hash -r
Configure Script Fails with Missing Compiler
If ./configure fails with errors about missing C compiler, first ensure you installed the build dependencies:
sudo dnf install gcc make
Afterward, run ./configure again.
Version Mismatch After Source Install
If sqlite3 --version shows an older version after compiling from source, the DNF-installed version may take precedence. To diagnose this, check which binary runs:
which sqlite3
/usr/bin/sqlite3
If both versions exist, remove the DNF package to use your source-compiled version:
sudo dnf remove sqlite
Conclusion
You installed SQLite on Fedora and verified it with a working test database. The DNF method provides automatic security updates and is recommended for most users, while source compilation gives developers access to the latest SQLite features. Explore additional SQL commands with .help in the SQLite shell, integrate SQLite databases with version-controlled projects using Git, or consider PostgreSQL on Fedora if your application requires a multi-user database server. For containerized deployments, see Docker on Fedora.