It sounds like the BDB database might not have been shut down properly or for some other reason cannot use its log file to recover. The error doesn't say which datafile has the problem.
Firstly, make sure you have made a backup of your wallet.dat
If the problem is with some file other than wallet.dat (which is more likely to be true) then you can use a utility that only uses wallet.dat.
There is a utility, pywallet, which will let you export the keys.
-
https://github.com/joric/pywallete.g., $ ./pywallet.py --dumpwallet --password="my encryption passphrase"
Otherwise, to do this within the bitcoin client you'ld need to either delete the blockchain and other data, index and log files (or pull a clean copy from the nightly snapshot). This will hopefully let you start up the client then.
As far as why you were getting the "can't connect to server" was probably because you weren't running a bitcoind server. Create a bitcoin.conf with rpcuser= and rpcpassword= , and then e.g..,
$ ./bitcoin-qt -server
$ ./bitcoind dumpprivkey [bitcoin address]
(if you have passphrase encryption, you'll need to open it first, e.g., for 1000 seconds)
$ ./bitcoind walletpassphrase [passphrase] 1000
then
$ ./bitcoind dumpprivkey [bitcoin address]
then close bitcoin-qt when done.