backtrack 5 does not come with a stand-alone postgresql server out-of-the box (R1 as well). metasploit though, comes with it's own built-in postgresql server and by-default connects to it on BT5 (type 'db_driver' on a fresh BT5 install or live boot, within msfconsole to see this in action -- note that /opt/framework/postgresql/data/ is where all the configs reside)! this HOWTO details how you can run your OWN postgresql server and get metasploit to interact with it.
right off the bat I want to thank sickness for his excellent tutorial => Metasploit db_autopwn using PostgreSQL which alot of this doc is sourced (verbatim) to get metasploit up and running. he is the person to be thanked here, I only tweaked things a little to work with BT5.
NOTE: it is NOT required to disable ssl in the postgresql.conf, as the server works without trouble simply be installing postgresql from package.
from there your good to go... I created the file /root/.msf4/msfconsole.rc with the following so I don't have to type the db_* commands each time ::
apt-get install postgresql libpq-dev
sudo su postgres -c psql
ALTER USER postgres WITH PASSWORD 'your password';
sudo passwd -d postgres
sudo su postgres -c passwd
<type the password for postgres account>
update-alternatives --config ruby
choose 0 for "auto-mode"
gem install pg
db_connect postgres:”postgreSQL_password”@127.0.0.1/metasploit (“metasploit” being the name of the database)
workspace -a <workspace>
lastly if you want to change the port postgresql runs on, change the 'port =' setting in the file /etc/postgresql/8.4/main/postgresql.conf then restart the server via '/etc/init.d/postgresql-8.4 restart'
(PS: the above works on BT5 R1 as well)