1、postgresql是本身没有启动的。所以需要启动。service postgresql start
2、通过命令进入配置sudo -u postgres psqlALTER USER postgres WITH PASSWORD ‘123.com’;注意1:‘123.com’这个是密码。注意2:分号!!!!一定要带上分号“;”。注意3:\q:退出数据库
3、修改linux系统的postgres用户的密码(密码与数据库用户postgres的密码相同)root@kali:~# sudo passwd -d postgrespasswd:密码过期信息已更改。root@kali:~# sudo -u postgres passwd输入新的 UNIX 密码:重新输入新的 UNIX 密码:passwd:已成功更新密码ps:截图上传太慢伤不起,具体内容就这些。
4、修改PostgresSQL数据库配置实现远程访问root@kali:~# vi /etc/postgresql/9.4/ma足毂忍珩in/postgresql.conf 更改#listen_addresses = ‘localhost’为 listen_addresses = ‘*’ 更改#password_encryption = on为password_encryption = onroot@kali:~# vi /etc/postgresql/9.4/main/pg_hba.conf在文档末尾加上以下内容 # to allow your client visiting postgresql server host all all 0.0.0.0 0.0.0.0 md5root@kali:~# service postgresql restart注意1:“#”号,一定要把“#”删除掉。注意2:在vi编辑模式下点击键盘字母a是进入编辑模式,编辑完成后点击“esc”退出编辑模式然后在最下方输入“:wq”保存并退出。
5、管理Po衡痕贤伎stgreSQL用户和数据库root@kali:~# psql -U postgres -h 127.0.0.1用户 postgres 的口令:psql (9.4.6)SSL连接 (协议: TLSv1.2, 加密:ECDHE-RSA-AES256-GCM-SHA384,二进制位: 256, 压缩比: 关闭)输入 "help" 来获取帮助信息.postgres=# create user "msf123" with password '123456' nocreatedb;CREATE ROLEpostgres=# create database “msf1” with owner=”msf123”;ERROR: role "”msf123”" does not existpostgres=# create database "msf1" with owner="msf123";CREATE DATABASEpostgres=# \q注意1:还是要注意分号!!!没有分号命令就无法执行。注意2:注意复制的时候“”符号问题。注意3:user后面是用户名,password后面是用户名对应的密码。注意4:命令执行后有返回结果才是执行成功了。
6、msf配置连接root@kali:~#msfconsolemsf > db_status[*] postgresql selected, no connectionmsf > db_connect msf123:[email protected]/msf1[*] Rebuilding the module cache in the background...msf > db_status[*] postgresql connected to msf1msf >在msf启动后连接数据库就好。注意1:“msf123:123456”这个是步骤5中的“create user "msf123" with password '123456' nocreatedb;”所建立的。“127.0.0.1”是指本机。“msf1”这个是库名。注意2:“[*] postgresql connected to msf1”这个是说明以链接成功数据库。