问题1复现路径:sql
postgresql selected, no connection数据库
第一步: db_connect postgres:toor@127.0.0.1/msfbookpost
链接成功不须要进行下一步编码
若失败:命令行
分析:postgresql
没有相关帐号和密码,因此没法链接it
解决方案:io
1. 在#命令行模式下,输入sudo -u postgres psql postgres // 来建立帐号console
2. 就会进入到postgres=#模式下,在msfconsole模式下输入 alter user postgres with password 'toor'; // 来修改密码coding
3. 显示ALTER ROLE // 修改生效
4. 退出postgres=#模式,从新输入db_connect postgres:toor@127.0.0.1/msfbook,就会出现一堆冗长的信息,这是建立链接数据表的过程,这只有在第一次建立postgres的msfbook库时出现冗长信息,之后就没有了,直接回到msf终端提示符。
提示:
记得开始进入msfconsole前,启动postgresql,命令以下:
1. service postgresql start
问题2现象:
根据以上的步骤进行建立链接数据库后,msf中会提示,建立时数据库编码错误,"Error while running command db_connect: Failed to connect to the database: PG::InvalidParameterValue: ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII) HINT: Use the same encoding as in the template database, or use template0 as template.: CREATE DATABASE "msfbook" ENCODING = 'utf8' Call stack:......"
分析:
默认数据库编码问题
解决方案:
1. sudo -u postgres psql postgres // 进入postgres用户PostgreSQL数据库模式中
2. 输入 create database msfbook with encoding='SQL_ASCII';
3. 显示 CREATE DATABASE // 建立成功