you could try this (source)
Download the Berkeley DB, uncompress it, and cd into the uncompressed directory:
wget http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz
tar -xzvf db-4.8.30.NC.tar.gz
cd db-4.8.30.NC/build_unix/
Then, configure the system for compiling, do the actual compile job with make (will take a good while), and then install Berkeley DB:
../dist/configure --enable-cxx
make
sudo make install