【发布时间】:2016-12-21 20:49:24
【问题描述】:
我在连接到数据库时遇到了以下错误:
无法连接到数据库。 请检查配置文件。
我尝试将$_DVWA[ 'db_server' ] 更改为'localhost',但这没有用,我尝试将$_DVWA[ 'db_port '] 链接到3306,但这也不起作用。密码为空。
配置文件如下所示:
<?php
# If you are having problems connecting to the MySQL database and all of the variables below are correct
# try changing the 'db_server' variable from localhost to 127.0.0.1. Fixes a problem due to sockets.
# Thanks to @digininja for the fix.
# Database management system to use
$DBMS = 'MySQL';
#$DBMS = 'PGSQL'; // Currently disabled
# Database variables
# WARNING: The database specified under db_database WILL BE ENTIRELY DELETED during setup.
# Please use a database dedicated to DVWA.
$_DVWA = array();
$_DVWA[ 'db_server' ] = '127.0.0.1';
$_DVWA[ 'db_database' ] = 'dvwa';
$_DVWA[ 'db_user' ] = 'root';
$_DVWA[ 'db_password' ] = '';
# Only used with PostgreSQL/PGSQL database selection.
$_DVWA[ 'db_port '] = '5432';
#this can be 3306 or 5432
# ReCAPTCHA settings
# Used for the 'Insecure CAPTCHA' module
# You'll need to generate your own keys at: https://www.google.com/recaptcha/admin/create
$_DVWA[ 'recaptcha_public_key' ] = '(did not want to disclose this)';
$_DVWA[ 'recaptcha_private_key' ] = '(did not want to disclose this)';
# Default security level
# Default value for the secuirty level with each session.
# The default is 'impossible'. You may wish to set this to either 'low', 'medium', 'high' or impossible'.
$_DVWA[ 'default_security_level' ] = 'impossible';
# Default PHPIDS status
# PHPIDS status with each session.
# The default is 'disabled'. You can set this to be either 'enabled' or 'disabled'.
$_DVWA[ 'default_phpids_level' ] = 'disabled';
# Verbose PHPIDS messages
# Enabling this will show why the WAF blocked the request on the blocked request.
# The default is 'disabled'. You can set this to be either 'true' or 'false'.
$_DVWA[ 'default_phpids_verbose' ] = 'false';
?>
有什么建议吗?
【问题讨论】:
-
你应该首先尝试附加到 PHP 之外的数据库。也许通过命令行 mysql 命令。
-
确保你已经启动了mysql和apache2服务
-
您正在使用 Postgres PORT,但尝试连接到 Mysql ?将端口
$_DVWA[ 'db_port ']更改为3306
标签: php mysql database penetration-testing