Fix metasploit “Database not connected or cache not built”

本文详细解释了如何解决使用Kali Linux(或Backtrack 5)时遇到的Metasploit实例未连接数据库的问题。常见错误提示为数据库未连接或缓存未构建,文章提供了检查数据库连接状态的方法,并指导用户启动PostgreSQL和Metasploit服务。如果数据库未连接,文章建议退出Metasploit控制台并启动服务。之后再次进入控制台,检查数据库是否已连接。若数据库已连接,则跳过下一步直接进行缓存构建。最后介绍了如何使用db_rebuild_cache命令构建或重建Metasploit缓存,确保快速辅助和漏洞搜索。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

转自:http://www.xuebuyuan.com/2044084.html

This is a short post explaining how to deal with metasploit instance not connected to its database (I’m using the new Kali Linux but it is the same for Backtrack 5). The issue usually surfaces when you try to search auxiliary or exploit.

Assuming that you use msfconsole you get something like this:

msf > search oracle

[!] Database not connected or cache not built, using slow search


The error says that there are 2 probable causes of the problem

- either your metasploit framework is not connected to its database (postgresql instance called msf3 by default)

- or the metasploit cache was not built.

To check if the database is connected you can use db_status command. If your database is connected you will get:


msf > db_status

[*] postgresql connected to msf3


If the database is connected you can skip the next step and go directly to “Step 2: Build the cache”.

Stpe 1: Start up PostgreSQL and Metasploit services

If the database is not connected exit your metasploit console and start both postgresql and metasploit services using the following commands:


#service postgresql start

#service metasploit start

Note: if you are using user different then root make sure that he has the privilege level to start those services

Start PostgreSQL and Metasploit Services

After you’ve dealt with both services start the msfconsole again and check if the database is connected using db_status again.

Note: If you want to start the postgresql and metasploit services on each reboot you need to use update-rc.d


#update-rc.d postgresql enable

#update-rc.d metasploit enable

Stpe 2: Build the cache

To build/rebuild metasploit cache use db_rebuild_cache command:


msf > db_rebuild_cache


It takes some time for the cache to be rebuild so be patient.

If all went OK you can now enjoy fast auxiliary/exploit search :)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值