How to Install SQLite 3 on Ubuntu 22.04 or 20.04

SQLite 3, a renowned lightweight relational database management system (RDBMS), stands out for its simplicity and efficiency, especially for applications on Ubuntu platforms. Understanding its unique features and advantages is crucial for those aiming to install SQLite 3 on Ubuntu 22.04 Jammy Jellyfish or its older stable release Ubuntu 20.04 Focal Fossa.

Key Advantages of SQLite 3 for Ubuntu Users:

  • Effortless Usability: SQLite 3’s design emphasizes ease, eliminating the need for intricate configurations and allowing developers to concentrate on application development.
  • High Portability: The entire database of SQLite 3 is contained within a single file, streamlining data transfers across devices or systems.
  • Resource Efficiency: With its compact nature, SQLite 3 is optimized for devices with resource constraints, from IoT gadgets to mobile devices.
  • Zero Configuration: SQLite 3’s seamless operation requires no preliminary setup, offering Ubuntu users a straightforward database solution.
  • Reliability: Ensuring data integrity, SQLite 3 adheres to ACID compliance, safeguarding transactions even during unforeseen system interruptions.

Comparing SQLite 3 with Other RDBMS:

Against MySQL:

  • SQLite 3’s compactness ensures minimal resource usage.
  • The absence of a separate server process simplifies SQLite 3’s setup.
  • Single-file database format enhances portability.

Against PostgreSQL:

  • SQLite 3 operates with a reduced memory and disk footprint.
  • It’s particularly apt for embedded applications or resource-limited devices.
  • SQLite 3’s interface prioritizes user-friendliness.

Given SQLite 3’s remarkable attributes and alignment with Ubuntu’s ethos, it emerges as a preferred RDBMS choice. The subsequent guide will elucidate the steps to install SQLite 3 on Ubuntu, ensuring you can leverage its capabilities.

Install SQLite 3 on Ubuntu 22.04 or 20.04 via APT

Step 1: Update Ubuntu Before SQLite 3 Installation

To ensure a smooth installation process and avoid potential conflicts, it is essential to update your Ubuntu system. This process updates all installed packages on your system to their latest available versions. To update your Ubuntu system, run the following command in your terminal:

sudo apt update && sudo apt upgrade

By running this command, you are using the apt package manager to update the package index and upgrade the installed packages to their latest versions.

Step 2: Install SQLite 3 on Ubuntu 22.04 or 20.04 via APT Command

The recommended approach for installing SQLite 3 on your Ubuntu system is to use the default APT repository. This method ensures that you install a stable, well-tested version of SQLite 3 that is compatible with your Ubuntu version. To start the installation process, run the following command in your terminal:

sudo apt install sqlite

This command uses the apt package manager to download and install the sqlite package on your system. The package manager handles any required dependencies and ensures that SQLite 3 integrates correctly with your Ubuntu system.

Step 3: Verify the SQLite 3 Installation on Ubuntu

After the installation, it’s essential to verify that SQLite 3 is installed correctly and functioning as expected. To do this, you can check the installed version of SQLite 3 by running the --version command:

sqlite3 --version

This command will display the installed SQLite 3 version in your terminal, allowing you to confirm that the installation was successful and that you have the desired version of SQLite 3 on your Ubuntu system.

Install SQLite 3 on Ubuntu 22.04 or 20.04 via Source

Step 1: Download the Latest SQLite 3 Archive on Ubuntu

If you prefer to compile SQLite 3 from the source, you can obtain the latest or a specific version by visiting the SQLite Download page. This method allows you to have more control over the version you install. First, identify the latest version of SQLite 3 on the download page. Then, use the wget command to download the appropriate archive:

wget https://www.sqlite.org/2023/sqlite-autoconf-{version}.tar.gz

Replace {version} with the actual version number. Always check the SQLite Download page for the most recent version.

For example:

wget https://www.sqlite.org/2023/sqlite-autoconf-3410200.tar.gz

Step 2: Extract the SQLite 3 Archive on Ubuntu

Once the archive is downloaded, extract the files using the following command:

tar xvfz sqlite-autoconf-*.tar.gz

This command uses the tar utility to extract the compressed archive into a new directory.

Step 3: Navigate to the Extracted Directory and Configure Prefix

Change the directory to the extracted folder to begin the compilation process:

cd sqlite-autoconf-{replace with version}

Replace {version} with the actual version number.

Now, configure the compilation with the desired installation prefix:

./configure --prefix=/usr
Sample output after configuring the SQLite path on Ubuntu 22.04 or 20.04.Pin
What to expect after setting up the SQLite path on Ubuntu 22.04 or 20.04.

Step 4: Compile SQLite with make Command on Ubuntu

To start the build process, use the make command along with the -j flag to specify the number of cores you want to utilize for faster compilation:

make -j {number_of_cores}

Replace {number_of_cores} with the desired number of cores for your system.

To determine the number of cores on your system, run the following:

nproc

For example, if your machine has two cores, use make -j 2. If you have 12 cores, you could use make -j 6 to dedicate half of your cores to the process.

Lastly, if the make command fails as the package is missing, run the following command:

sudo apt install build-essential
Sample 'make' output from compiling SQLite on Ubuntu 22.04 or 20.04.Pin
A glimpse into the ‘make’ process when compiling SQLite on Ubuntu 22.04 or 20.04.

Step 5: Install SQLite 3 on Ubuntu 22.04 or 20.04 via Compiled Binary

After the build process is complete, install SQLite using the following command:

sudo make install

The installation process will display output indicating the progress. Once installed, verify the installation and the version number:

sqlite3 --version
Sample output from the 'make install' command for SQLite on Ubuntu 22.04 or 20.04.Pin
The aftermath of executing the ‘make install’ command for SQLite on Ubuntu 22.04 or 20.04.

Conclusion

This article covers two methods for installing SQLite on Ubuntu Linux: using the APT package manager and compiling from the source. Installing SQLite using the APT package manager provides a stable, well-tested version compatible with your Ubuntu system. On the other hand, compiling SQLite from the source allows you to have more control over the version you install and stay up-to-date with the latest features and improvements. Following the steps, you can successfully install SQLite 3 on your Ubuntu system and start using this powerful, lightweight relational database management system in your projects.

Share to...