Here goes a quick tip, but mostly a reminder to myself. After a fresh install of your favorite pentest distro, upon making a search on the Metasploit for the first time you’ll get the warning message below:

[!] Module database cache not built yet, using slow search

What to do? The answer is quite simple.

First, from the Metasploit, make sure the db is not connected.

msf > db_status
[*] postgresql selected, no connection

Now just leave the MSF and use the command msfdb init to initialize the Database.

root@parrot:~# msfdb init

[i] Database already started
[+] Creating database user 'msf'
[+] Creating databases 'msf'
[+] Creating databases 'msf_test'
[+] Creating configuration file '/usr/share/metasploit-framework/config/database.yml'
[+] Creating initial database schema
rake aborted!

Now back in the MSF, the db_status should look like this:

[*] postgresql connected to msf

We are almost done here, just rebuild the cache to have your searches at the regular speed.

[*] Purging and rebuilding the module cache in the background...

Done!