CentOSRHEL Based

How To Install SQLite on CentOS Stream 10

Install SQLite on CentOS Stream 10

SQLite is a lightweight, self-contained relational database management system widely used in a variety of software, including web applications, development environments, and even embedded systems. It stands out because of its small footprint, portability, and ability to function without the need for a separate server process. CentOS Stream 10 is the rolling-release version of CentOS, providing the latest packages and features that align closely with Red Hat Enterprise Linux development. Installing SQLite on CentOS Stream 10 is a straightforward process, but ensuring that the steps are carried out correctly can save time and prevent avoidable issues down the road.

This guide offers two main methods for installing SQLite: one using the default package manager (dnf or yum) and another by compiling from source. Both methods allow control over the SQLite version installed, making it easier to keep up with new features or to stick to stable releases. Along the way, common troubleshooting tips and additional resources will be provided. By the end, you will be able to verify your setup, perform basic usage commands, and properly manage SQLite databases on your CentOS Stream 10 environment with confidence.

Prerequisites

Before starting, it is essential to go through a short checklist of prerequisites to guarantee a seamless installation. First and foremost, you need a running CentOS Stream 10 system with administrative privileges. Having sudo or root access is crucial for installing packages or for compiling programs from source. Also, ensure that your system is up to date, as this reduces the risk of conflicts or dependency issues. Use the following commands:

sudo dnf update
sudo dnf upgrade

After updating, verify that you have a steady internet connection, because downloading packages from the official repositories is common practice on CentOS Stream 10. Disabling or adjusting any firewall settings that may block HTTP or HTTPS might also be necessary in some restricted environments.

Lastly, confirm that you have adequate disk space for both the SQLite installation and any future databases. Although SQLite itself is small, databases can grow depending on usage. Ensuring you meet these requirements upfront will save time and will facilitate a smoother SQLite installation process on CentOS Stream 10.

Method 1: Installing SQLite Using Package Manager

Deploying SQLite directly from the official CentOS Stream 10 package repository is the most convenient option if you do not require the latest bleeding-edge features. It is faster than compiling from source and keeps consistency with your system’s package database. This approach also simplifies any future upgrades or patches.

Updating Your System

Before installing anything new, it is best practice to confirm your system’s package list is in sync with the official repositories. CentOS Stream 10 uses dnf as the default package manager, though some might still refer to it as yum. To avoid confusion and ensure you have the most up-to-date metadata, run:

sudo dnf update

This command refreshes the repository data so that when you install SQLite, you receive the appropriate version from the CentOS Stream 10 repos. If there are any system updates available, go ahead and update them. After that, the system will be ready to proceed with the SQLite installation.

Installation Steps

With your system updated, initiating the SQLite installation is straightforward. Type:

sudo dnf install sqlite

Depending on the repository configuration, the package may appear as sqlite or sqlite3. Both reference the SQLite package in many instances, but sqlite is commonly used in CentOS-based distributions. Once prompted, confirm by typing y to proceed. The package manager automatically resolves dependencies and installs the necessary libraries. For those using older or alternate package managers, the command may look like:

sudo yum install sqlite

But under CentOS Stream 10, you will typically be using dnf. After the installation completes, the binaries, libraries, and essential files are placed under your system’s default paths.

Verification of Installation

To ensure everything worked as expected, check the SQLite version installed:

sqlite3 --version

The output will display the SQLite version number and confirm your setup. You can also launch the SQLite shell with:

sqlite3

When you see the prompt that says something like sqlite>, type .help to confirm you are connected to the SQLite CLI. Exit the shell by typing .exit or pressing Ctrl + D.

At this point, SQLite is installed and fully operational from the system’s repositories. This method is preferred for users who want quick and stable deployment under CentOS Stream 10 without additional complexity.

Method 2: Installing SQLite from Source

Installing SQLite from source is recommended if you need the absolute latest version or specific compile-time options that are not available in the CentOS Stream 10 repositories. This method offers granular control but requires more steps and an understanding of compiling tools. Below is a detailed process that you can follow.

Downloading the Source Code

To acquire the newest stable release of SQLite, visit the official SQLite website and download the sqlite-src-<version>.tar.gz file. Alternatively, if you prefer the command-line approach, you can use wget to fetch the source:

wget https://www.sqlite.org/2023/sqlite-autoconf-<version>.tar.gz

Replace <version> with the actual version you need. Always try to match stable releases for a smoother experience. After downloading, verify the file integrity with checksums if available. Verification helps guarantee that the file has not been corrupted or tampered with.

Preparing Tools and Dependencies

Before compiling, confirm that build-essential tools, such as gcc, make, and other necessary libraries, are installed on your CentOS Stream 10 system. Use the following:

sudo dnf groupinstall 'Development Tools'
sudo dnf install tcl

The TCL package is often recommended because some of SQLite’s test suite leverages Tcl code. Installing it is optional but considered a good practice if you want to perform a thorough test of your new SQLite build.

Extraction and Configuration

Extract the source files into a directory using:

tar xvfz sqlite-autoconf-<version>.tar.gz
cd sqlite-autoconf-<version>

Within this directory, configure the source:

./configure --prefix=/usr/local

Adjust the –prefix path if you want to install SQLite in a different location. The above command instructs the build system to set /usr/local as the destination path for the SQLite binaries once compiled. The ./configure step also checks your system and lists any missing dependencies that must be resolved before proceeding.

Compilation Process

After configuration completes successfully, compile SQLite:

make -j$(nproc)

This command uses all available CPU cores for faster compilation. The -j$(nproc) parameter is optional but is often used to speed things up by parallelizing the build. If no errors appear, you are prepared to install. Next, install SQLite system-wide:

sudo make install

This places the SQLite binaries in /usr/local/bin (unless you used a different prefix). The library files go to /usr/local/lib, and other relevant documentation will end up under /usr/local/share.

Environment Variable Setup

In some situations, you might need to update environment variables so the new SQLite can be found easily. For instance:

echo "export PATH=/usr/local/bin:$PATH" | sudo tee /etc/profile.d/sqlite.sh
source /etc/profile.d/sqlite.sh

This ensures that the just-compiled version of SQLite is prioritized over older system versions. If you do not have a prior version installed, this step might be unnecessary. However, it is good practice if you plan on eventually installing multiple versions or want to ensure the new binary is recognized system-wide.

With this source-based approach, you now have control over which features are included and can access the newest SQLite features—even before they appear in the standard CentOS repositories. Remember, though, that you will have to manually update and recompile SQLite when official releases become available.

Post-Installation Setup

Once SQLite is installed using either method, take a few steps to ensure it is operational and meets your use case requirements. Verification tests are especially relevant if you compiled it from source.

Verification

To confirm the runtime environment is correct, use:

sqlite3 --version

This command displays the exact build and version number of your SQLite installation. If you installed from source and want to run a deeper test suite (often included by default in the SQLite package), you can run:

make test

in the source directory (before running sudo make install) to confirm that all features work as expected. Not everyone requires these tests, but they can detect rare compatibility or dependency conflicts early.

Basic Configuration Checks

If you prefer a custom location or library path, verify that your environment variables, such as LD_LIBRARY_PATH, reflect the correct directories. For a system-level installation, typically no further adjustment is necessary. But if you installed it in /opt or /usr/local, confirm that those locations are correctly recognized in your PATH.

With these post-installation tasks completed, SQLite is now ready for day-to-day usage on CentOS Stream 10. Next, it is worth learning a few basic usage commands to get started managing your first SQLite databases.

Basic Usage Guide

SQLite offers an interactive shell (sqlite3) that allows immediate execution of SQL queries in real time. Launch the shell using:

sqlite3

Inside the SQLite prompt, use .help to see a list of available commands and .exit or .quit to leave the shell. Here is how to create and interact with a new database:

sqlite3 mydatabase.db

This command opens or creates (if it does not exist) mydatabase.db. Then you can issue standard SQL instructions, like creating a table:

CREATE TABLE users(
  id INTEGER PRIMARY KEY,
  username TEXT NOT NULL,
  email TEXT NOT NULL
);

After creating the table, insert data with:

INSERT INTO users (username, email) VALUES ('testuser','test@example.com');

And retrieve entries using:

SELECT * FROM users;

Since SQLite stores its entire database in a single file, you can easily move or copy mydatabase.db to another system. This portability makes SQLite an appealing choice for projects where you need a small, yet reliable database solution on CentOS Stream 10.

Troubleshooting Common Issues

Despite SQLite being easy to install and maintain, occasional issues can arise. Here are a few to watch for:

  • Permission Problems: Ensure that the directories storing SQLite databases have writable permissions. If a database is read-only, SQLite cannot perform insertions or updates.
  • Path Variable Conflicts: After compiling from source, older system versions might still take precedence. Verify your PATH points to the correct location.
  • Library Dependencies: Missing libraries or mismatched library versions can cause runtime errors. Reinstall or link them properly to resolve these conflicts.

Most of these issues can be resolved by confirming environment variables, checking system logs, and ensuring that the SQLite installation path is properly recognized.

Congratulations! You have successfully installed SQLite. Thanks for using this tutorial to install the SQLite database on CentOS Stream 10. For additional help or useful information, we recommend you check the official SQLite website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button