msfconsole >db_status postgresql selected,no connect >msfdb init System has not been booted with systemd as init system (PID 1). Can't operate.
原理是wsl启动的时候没systemd。
解决方法
启动数据库服务
1 2 3
msfdb init sudo service postgresql start sudo service postgresql status
手动建立数据库用户,数据库
1 2 3 4 5 6 7
# cd /etc/postgresql/13/main sudo -u postgres psql alter user postgres password 'root'; create user msf with password 'metasploit' createdb; create database msf with owner=msf; quit
Connecting Metasploit to the database in WSL can be a bit tricky. Following the normal procedure might result in the following error:
1 2 3 4 5
msfconsole > db_status postgresql selected,no connect > msfdb init System has not been booted with systemd as init system (PID 1). Can't operate.
The reason is that WSL does not start with systemd.
Solution
Start the database service
1 2 3
msfdb init sudo service postgresql start sudo service postgresql status
Manually create the database user and database
1 2 3 4 5 6 7
# cd /etc/postgresql/13/main sudo -u postgres psql alter user postgres password 'root'; create user msf with password 'metasploit' createdb; create database msf with owner=msf; quit