How to upgrade SQLite3 in OS X.
SQLite 3.10.0 was just released. SQLite is already installed in OS X, but it’s always nice to upgrade to a newer version, and OS X is usually kind of slow on that.
On the SQLite Download Page you can find precompiled binaries for OS X, including a sqlite3_analyzer
tool.
Download
I’m using wget
.
wget https://www.sqlite.org/2016/sqlite-shell-osx-x86-3100000.zip
wget https://www.sqlite.org/2016/sqlite-analyzer-osx-x86-3100000.zip
If you haven’t done the HTTPS-fix ..» for wget
, you will likely get an error about “https”. Then use: wget --no-check-certificate
instead.
Verifying… You can find the checksums on the download page… If you are using my chksum
..», then you can just run:
chksum sha 048ec8430775c60c2a670e85aba1ee0d6082523b sqlite-shell-osx-x86-3100000.zip
chksum sha a13985e2cbce13e6bb3115727f8b8d58e67d9486 sqlite-analyzer-osx-x86-3100000.zip
It will tell you “OK” or “FAILED”.
Unzip the files…
unzip sqlite-shell-osx-x86-3100000.zip
unzip sqlite-analyzer-osx-x86-3100000.zip
Installing
The OS X version sits in /usr/bin
, and now with the latest version(s) of OS X there is also this new SIP which prevents installations etc in that area. So, we’ll use /usr/local/bin
. Make sure that is in front of PATH
in your ~/.bashrc
, or ~/.bash_profile
if you’re using that one.
export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
To install:
sudo install -m755 sqlite3{,_analyzer} /usr/local/bin
Verify:
$ which sqlite3{,_analyzer}
/usr/local/bin/sqlite3
/usr/local/bin/sqlite3_analyzer
$ sqlite3 -version
3.10.0 2016-01-06 11:01:07 fd0a50f0797d154fefff724624f00548b5320566
Now, if you do have access to /usr/bin
(disabled SIP or using an earlier version of OS X), you could back up the original file…
cd /usr/bin
sudo mv sqlite3{,.orig.bak}
# remove the exec if you want to
# sudo chmod -x sqlite3.orig.bak
…and add a symlink to the new one(s).
sudo ln -s /usr/local/bin/sqlite3 .
sudo ln -s /usr/local/bin/sqlite3_analyzer .
Happy hacking…
/Eric