How to upgrade SQLite on OS X Mavericks / Yosemite

OS X 10.9 Mavericks comes with pre-installed SQLite 3.7.13, and OS X 10.10 Yosemite comes with version 3.8.5. At the time of this writing, SQLite version 3.8.6 is already available. This post would like to show you how to upgrade SQLite in OS X to the latest version.

This tutorial should be also applicable for previous Mac OS X versions such as OS X 10.7 Lion and OS X 10.8 Mountain Lion.

SQLite

1. Run ‘sqlite3’ in the Terminal app to show the installed SQLite version.

$ sqlite3 
SQLite version 3.7.13 2012-07-17 17:46:21
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> 

2. Go to http://www.sqlite.org/download.html page and download the Precompiled Binaries for Mac OS X (sqlite-shell-osx-x86-3080600.zip)

3. Unzip the ‘sqlite-shell-osx-x86-3080600.zip’ file so you will get the new ‘sqlite3’ file.

4. Backup the current version of SQLite and make it non-executable file.

$ which sqlite3
/usr/bin/sqlite3
$ sudo mv /usr/bin/sqlite3 /usr/bin/sqlite3-old
$ sudo chmod -x /usr/bin/sqlite3-old 

5. Now move the new downloaded sqlite3 file to /usr/bin/ directory and make it executable.

$ sudo mv sqlite3 /usr/bin/
$ sudo chmod +x /usr/bin/sqlite3

6. Verify that SQLite has been upgraded by issuing ‘sqlite3’ command in Terminal

$ sqlite3 
SQLite version 3.8.6 2014-08-15 11:46:33
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> 

You can see on the above that the SQLite has been successfully upgraded to version 3.8.6