SQLite is a free, lightweight relational database management system (RDBMS) in a C library. SQLite is not a client-server database engine. Instead, it is embedded into the end program. Primarily all programming languages support SQLite, which how languages embed the program is with a file with .sqlite3/.sqlite/.DB extension. The software is popular for local/client storage such as web browsers, Android devices, etc. The list is quite extensive.
The following tutorial will teach you how to install SQLite 3 with CentOS 9 Stream using the command line terminal using the standard DNF package manager or manually installing straight from the project’s Git.
Update CentOS Stream
First, update your system to ensure all packages are up-to-date to avoid any conflicts during the installation.
sudo dnf upgrade --refresh
Install SQLite 3 – DNF Method
The first option and recommended to start with is to install SQLite 3 from the default appstream. To begin the installation, use the following command in your terminal.
sudo dnf install sqlite3
Next, verify the version of SQLite 3 with the –version command.
sqlite3 --version
Install SQLite 3 – Download & Compile Method
As many users would know, the version featured in the default repository is not always the most up-to-date, and compiling can give you the latest, or for that matter, a preferred version.
First, install the dependencies required as follows.
sudo dnf install make automake cmake gcc -y
Next, visit the SQLite Download page, grab the latest version link, and download it using the wget command.
wget https://www.sqlite.org/2022/sqlite-autoconf-{version}
Example:
wget https://www.sqlite.org/2022/sqlite-autoconf-3390000.tar.gz
DO NOT FORGET TO CHECK THE DOWNLOAD PAGE, AS IN TIME, THE ABOVE LINK COMMAND WILL BE OBSOLETE.
Extract the files to that directory you just created.
Example:
tar xvfz sqlite-autoconf-3390000.tar.gz
Move the file to the directory created earlier.
sudo mv sqlite-autoconf-3390000 /opt/sqlite3
Now, you will navigate to the folder to begin compiling SQLite.
cd /opt/sqlite3
Begin the compiling process using the following command.
./configure --prefix=/usr
The following process uses the (make) command to start the build process. A better way to do this is to specify the number of cores you want to use in compiling to speed up the process.
make -j 2
Note that the (-j) corresponds to the number of cores in your system to speed up the build time. If you have a powerful server, you can set this as high as possible. If you don’t, it will be the default option of 1. To find out how many cores you have on your system, execute the following code:
nproc
For example, your machine has 2 cores, so in the (make) command, you will use (-j 2). However, if you have 12 cores, you could have (-j 6) cores and dedicate half or more to the process.
Once the build process is complete, begin the installation using the following command.
sudo make install
Once installed, verify the installation and the version number.
sqlite3 --version
Comments and Conclusion
If you are looking for a lightweight yet powerful database solution that can be embedded into your applications, SQLite is a great choice. It is free to use, and there are plenty of resources available online if you need help getting started; I would first recommend visiting the SQLite official documentation page.