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, and much more. The list is quite extensive.

In the following tutorial, you will learn how to install SQLite 3 along with Ubuntu 20.04 LTS Focal Fossa.

Advertisement

Prerequisites

  • Recommended OS: Ubuntu 20.04 or higher
  • User account: A user account with sudo or root access.

Update Operating System

Update your Ubuntu operating system to make sure all existing packages are up to date:

sudo apt update && sudo apt upgrade -y

The tutorial will be using the sudo command and assuming you have sudo status.

To verify sudo status on your account:

sudo whoami

Example output showing sudo status:

[joshua@ubuntu ~]$ sudo whoami
root

To set up an existing or new sudo account, visit our tutorial on How to Add a User to Sudoers on Ubuntu.

To use the root account, use the following command with the root password to log in.

su

The tutorial will utilize the terminal interface, which can be found in the show applications menu.

Example:

How to Install SQLite 3 on Ubuntu 20.04 LTS

Option 1. Install SQLite 3 on Ubuntu with APT

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
Advertisement

Option 2. Install SQLite 3 on Ubuntu by Compiling

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

Example output:

How to Install SQLite 3 on Ubuntu 20.04 LTS

Type Y, then press the ENTER KEY to proceed.

Next, visit the SQLite Download page and 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 next process is to use 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, we used (-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

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 the time of this tutorial.

Advertisement

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.

Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
adplus-dvertising
0
Would love your thoughts, please comment.x
()
x