打开postgresql服务
root@wu:~# service postgresql start
进入postgresql
root@wu:~# sudo -u postgres psql
信息查看
postgres=# \du
角色列表
角色名称 | 属性 | 成员属于
----------+--------------------------------------------+----------
postgres | 超级用户, 建立角色, 建立 DB, 复制, 绕过RLS | {}
更改密码
postgres=# \password
输入新的密码:
再次输入:
postgres权限太高,新建一个用户和数据库来连接metasploit
CREATE USER 用户名 WITH PASSWORD 密码 NOCREATEDB;
postgres=# CREATE USER msfdb1 WITH PASSWORD '000000' NOCREATEDB;
CREATE ROLE
给新建的用户新建一个数据库
CREATE DATABASE 数据库名 OWNER 用户名;
postgres=# CREATE DATABASE msf_db OWNER msfdb1;
CREATE DATABASE
查看数据库
postgres=# \l
数据库列表
名称 | 拥有者 | 字元编码 | 校对规则 | Ctype | 存取权限
-----------+----------+----------+----------+---------+-----------------------
msf_db | msfdb1 | UTF8 | C.UTF-8 | C.UTF-8 |
postgres | postgres | UTF8 | C.UTF-8 | C.UTF-8 |
template0 | postgres | UTF8 | C.UTF-8 | C.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | C.UTF-8 | C.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(4 行记录)
打开msfconsole
root@wu:~# msfconsole
查看数据库连接情况
msf > db_status
[*] postgresql selected, no connection
连接刚刚新建的数据库
db_connect 用户名:密码@127.0.0.1/数据库
msf > db_connect msfdb1:000000@127.0.0.1/msf_db
[*] Rebuilding the module cache in the background...
msf > db_status
[*] postgresql connected to msf_db