Fatal error: Uncaught Exception: CRITICAL. Error attempting to open MySQL connection.
m-naeem66622 opened this issue · 7 comments
When goto the 127.0.0.1 on my browser, I got warning at the top
Warning: fsockopen(): Unable to connect to 127.0.0.1:389 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) in C:\xampp\htdocs\database-offline.php on line 105
And i also found a big text highlighted
The database server at 127.0.0.1 appears to be offline.
By clicking the first option "Click here to attempt to setup the database. Sometimes this works"
I got the error:
Fatal error: Uncaught Exception: C:\xampp\htdocs\classes\MySQLHandler.php on line 147: C:\xampp\htdocs\classes\MySQLHandler.php on line 138: Access denied for user 'root'@'localhost' (using password: YES) CRITICAL. Error attempting to open MySQL connection. Try checking the connection settings in the MySQLHandler.php class file. If there is a problem connecting, usually one of these settings is incorrect (i.e. - username, password, database name). It is also a good idea to make sure the database is running and that the web site (Mutillidae) is allowed to connect. This error was generated by public function __construct(). Tried to connect with username root, password mutillidae, and hostname 127.0.0.1 (1045) [mysqli_sql_exception] <br /> CRITICAL. Error attempting to open MySQL connection. Try checking the connection settings in includes/database-config.php. If there is a problem connecting, usually one of the settings is incorrect (i.e. - username, password, database name). It is also a good idea to make sure the database is running and that the web site (Mutillidae) is allowed to connect. This error was generated by function doOpenDatabaseConnection() (0) [Exception] <br /> in C:\xampp\htdocs\classes\MySQLHandler.php:177 Stack trace: #0 C:\xampp\htdocs\classes\MySQLHandler.php(104): MySQLHandler->doOpenDatabaseConnection() #1 C:\xampp\htdocs\set-up-database.php(20): MySQLHandler->__construct('owasp-esapi-php...', 0) #2 {main} thrown in C:\xampp\htdocs\classes\MySQLHandler.php on line 177
Hello. The database appears to be running on port 3306 in your configuration, which makes sense because 3306 is the default port for MySQL server and Maria DB. However, the error says that the database configuration is pointing to port 389. 389 is the port for the directory server rather than the database server. You might check the database configuration file and change the port to 3306.
which configuration file? Can you plz tell how it can be done? I don't know about php or any backend language
The Database Configuration file is in /includes/database-config.inc. Please see https://github.com/webpwnized/mutillidae/blob/master/includes/database-config.inc
Based on the configuration, I think the issue is Mutillidae is trying to connect to the Directory Service, but the service is either not available or not installed. For example, the containerized version of Mutillidae uses an OpenLDAP container to provide Mutillidae an LDAP backend. Since your error is on port 389 (LDAP port), I think the Directory Service is offline or not installed. I will look at making the directory service optional. You might consider running Mutillidae Docker as a workaround.
I think you are paying attention only on Warning: fsockopen(): Unable to connect to 127.0.0.1:389
.
It's just the warning as i think that is displayed on the top. But the real issue I mentioned at the last. I am not able setup my database. By clickig on Click Here.
Fatal error: Uncaught Exception: C:\xampp\htdocs\classes\MySQLHandler.php on line 147
. For more detail about error read the first comment from the last.
Unfortunately, the issue is not occurring on my system so I cannot replicate the issue. You might check the database itself by manually logging into MySQL using the mysql client software. That way you can check for yourself what username, password, and port are correct, then copy those over to the configuration file. Use the username, password, port that the database was set up with to test whether the root account can log in.