Install the Latest SQLite3 on Linux (Easy, Beginner Friendly, No Compilation)

blog cover image

In this tutorial we’ll install the latest binaries for sqlite3 in linux (distro unspecific) , the principle is straightforward and can be applied with few commands but I decided to use easy & typo-friendly commands for new linux users to learn something or two about the linux world !

1- Get the Precompiled Binaries for linux

From the sqlite3 download page find and download the precompiled Binaries for Linux (they don’t need compilation yay!)

2- Unzip & Test them

Believe it or not ,It’s easier to use terminal for this , using GUI is always an option if you understands the principle .

in the terminal cd (change directory) to the directory that holds the downloaded zip (usually Downloads) and unzip the file(make sure to change VERSION_NUMBER to the correct name)

Bonus: just start typing the version numbers and hit tab for auto completion

cd ~/Downloads  
unzip sqlite-tools-linux-x86-VERSION_NUMBER.zip
  • cd into the resulting directory and test the binaries (notice we’re using ./ to indicate that we want to run the binary from current location :
cd sqlite-tools-linux-x86-VERSION_NUMBER/  
./sqlite3 --version  
# OUTPUT:  
# 3.35.5 2021-04-19 18:32:05

2- Remove old SQLite3 installation (if found)

You can remove it using the default Package Manger in your linux distribution e.g sudo apt-get remove sqlite3 for Debian based distros (Ubuntu, Mint , MX ..etc) this may however cause other packages depending on it to be removed so I went with Option 2 :

  • Backing up old binaries (optional since you can always re-install them using package manager) :
mkdir ~/.oldsqlite_backup  
cp $(which sqlite3) ~/.oldsqlite_backup  
cp $(which sqldiff) ~/.oldsqlite_backup
  • Manually Removing Old binaries
sudo rm $(which sqlite3) $(which sqldiff)

3- Make the new Binaries System-wide:

System-wide (aka: you can execute them from any location without the need to change to their directory) to do that we need to

  • First , to keep things clean we’ll create a directory that holds our binaries together in the /opt/ directory
cd /opt/  
sudo mkdir sqlite3
  • Second we copy the Precompiled binaries to that location
cd ~/Downloads/sqlite-tools-linux-x86-VERSION_NUMBER/  
sudo cp * /opt/sqlite3

* means copy all files

  • Finally we make links for the binaries in a directory where the system can find them (a directory that’s present in $PATH) I chose “/usr/local/bin

cd /opt/sqlite3/  
sudo cp -l * /usr/local/bin/

There you have it ! the latest sqlite3 is now installed , I want to make a quick Note : if you want to re-install your system’s default sqlite3 make sure to rename or remove the new binaries links in /usr/local/bin

Why Updating

Was trying to learn about SQLite3 (as part of CS50’s Web Programming course ), I made a mistake in the table column name , tried renaming it using instructions from documentation but got stuck because my installed version didn’t support the new renaming syntax.

ALTER TABLE RENAME COLUMN

A simple apt update / install didn’t work , and I wasn’t prepared mentally to go through compilation 😄.