How to Install SQLite 3 on Ubuntu 20.04 LTS

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 a popular choice for local/client storage such as web browsers, Android devices, etc. The list is quite extensive.

In the following tutorial, you will learn how to install SQLite 3 and Ubuntu 20.04 LTS Focal Fossa using the command line terminal with two different installation methods.

Update Ubuntu

First, update your system to ensure all existing packages are up to date to avoid any conflicts during the installation and for good system maintenance.

sudo apt update && sudo apt upgrade -y

Install SQLite 3 – APT Method

The first option and recommended to start with is to install SQLite 3 from the default APT repository. To begin the installation, use the following command in your terminal.

sudo apt install sqlite3

Next, verify the version installed of SQLite 3 with the –version command.

sqlite3 --version

Example output:

How to Install SQLite 3 on Ubuntu 20.04 LTS

Install SQLite 3 – Download & Compile Method

As many Ubuntu users would know, the version featured in Ubuntu’s 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 build-essentials package.

sudo apt install build-essential -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-3370200.tar.gz

Extract the files to that directory you just created.

Example:

tar xvfz sqlite-autoconf-3370200.tar.gz

Move the file to the directory created earlier.

sudo mv sqlite-autoconf-3370200 /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 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 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

Example output:

2

As you can see, we have two cores, so in the (make) command, the tutorial used (-j 2) to speed the process up.

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

Example output:

How to Install SQLite 3 on Ubuntu 20.04 LTS

As above, the version is 3.37, whereas the Ubuntu repository version is at 3.31 at this tutorial.

Note that the above versions in time will change; this is just an example at the time of the tutorial of the differences.

Comments and Conclusion

The tutorial has shown how to install SQLite 3 using the APT method or compiling from source with Ubuntu 20.04 LTS. Overall, SQLite 3 is basic but powerful. However, it is acceptable for small to medium websites for large growing sites to look at MariaDB, MongoDB, and PostgreSQL, among many other options.

For more information on building applications with SQLite, visit the official documentation page.



Follow LinuxCapable.com!

Like to get automatic updates? Follow us on one of our social media accounts!