"Uncaught mysqli_sqli_exception" error on Windows installation

PHP Fatal error: Uncaught mysqli_sql_exception

Apologies if I describe anything incorrectly! Iā€™m not too familiar with programming/computer jargon in general.

OS: Windows 11 Pro
Web server: mySQL/Apache server using Xampp
PHP version: 8.2.12
SuiteCRM: 7.14.4
Database: mySQL (?)

This is the error that I keep running into on the database configuration page in the setup wizard. As far as I know, the username and password that are present in the mySQL database are correct, but the program doesnā€™t seem to like those and keeps giving me the following fatal error.

Fatal error : Uncaught mysqli_sql_exception: Access denied for user ā€˜dbuserā€™@ā€˜localhostā€™ (using password: YES) in C:\xampp\htdocs\SuiteCRM-7.14.4\include\database\MysqliManager.php:322 Stack trace: #0 C:\xampp\htdocs\SuiteCRM-7.14.4\include\database\MysqliManager.php(322): mysqli_connect(ā€˜localhostā€™, ā€˜dbuserā€™, Object(SensitiveParameterValue), ā€˜ā€™, NULL) #1 C:\xampp\htdocs\SuiteCRM-7.14.4\install\checkDBSettings.php(141): MysqliManager->connect(Array, false) #2 C:\xampp\htdocs\SuiteCRM-7.14.4\install.php(357): checkDBSettings() #3 {main} thrown in C:\xampp\htdocs\SuiteCRM-7.14.4\include\database\MysqliManager.php on line 322

Line 322 contains code that looks like this, for someone that isnā€™t familiar with programming languages itā€™s not really presenting an intuitive piece of information that I can easily figure out:
$this->database=@mysqli_connect(

I would appreciate any help! Let me know if thereā€™s anything else that I can provide, apologies again if I was incorrect/inconsistent about anything!

Looks like your database username / password is incorrect. You can check, config.php file

I have the username set as ā€˜userā€™ and the password as a number-only password. I saved it in that config file, restarted the server, and attempted to log in again with that same information, but was met with the same error.

Maybe check your file permissions and ownership. I donā€™t know how to do it for windows. You can search in this forum.

Since PHP 8.1, the default error handling behavior of the MySQLi extension has changed from silencing errors to throw an Exception on errors.

Note: Prior to PHP 8.1, the default error reporting mode in MySQLi was to silence the errors, and often lead to code that did not follow proper Exception/Error handling. From PHP 8.1 and later, the default error reporting mode is to throw an Exception on errors.

MySQLiā€™s default error mode is changed from MYSQLI_REPORT_OFF to MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT

This change is similar to PDO extension, its default error handling mode has been changed from ā€œsilentā€ to ā€œexceptionsā€ since PHP 8.0.

Prior to PHP 8.1, an error in the extension, database, query, or the database connection returned false and emitted a PHP warning.

$mysqli = new mysqli("localhost", "non-existing-user", "", "");
Warning: mysqli::__construct(): (HY000/2002): No connection could be made because the target machine actively
refused it in ... on line ...

From PHP 8.1 and later, the default error mode is set to MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT.

$mysqli = new mysqli("localhost", "non-existing-user", "", "");
Fatal error: Uncaught mysqli_sql_exception: Connection refused in ...:...

Backwards Compatibility Impact

This is a breaking change because the default value is different in PHP 8.1, causing the runtime behavior to be different - Exception for any error.

For compatibility across PHP versions prior to PHP 8.1, it is possible to explicitly set the error handling mode using mysqli_report function before the first MySQLi connection is made. It is also possible to instantiate a mysqli_driver instance, and set the error reporting value.

Note that mysqli_driver class has a mono-state pattern, which means once the error reporting value is set, it affects all MySQLi connections throughout the request unless the value is later overwritten in another call. The same applies for the mysqli_report function as well.


Configure PHP 8.1 behavior (Exceptions) in all PHP versions:

 mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT);

or

$driver = new mysqli_driver();  
$driver->report_mode = MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT;

Configure PHP < 8.1 behavior (return false and emit a warning) in all PHP versions:

mysqli_report(MYSQLI_REPORT_OFF);

or

$driver = new mysqli_driver();
$driver->report_mode = MYSQLI_REPORT_OFF;

Using Exceptions (default behavior in PHP 8.1) is recommended, because it surfaces errors that would have gone unnoticed. To prevent sensitive data leakage, configure the display_errors INI value to off. With MYSQLI_REPORT_OFF, the caller must handle the errors by checking the return value of mysqli_* function calls, or by checking the $mysqli->error property.

For your issue, try to insert this before line 322:

mysqli_report(MYSQLI_REPORT_OFF);

If your install still fails, and you are able to, switch to PHP 7.4 or 8.0, run the install. After install is complete switch your PHP to PHP 8.2.

1 Like

This solved the specific error! Thank you so much!

Now the only thing that is popping up is an inability to connect to the database due to invalid database host, username, and/or password. However, the information that Iā€™m inputting in the Setup Wizard screen matches what is in my config.php folder. Would you have any idea why itā€™s still not letting me in?

1 Like

Maybe your host is localhost.

Thatā€™s what Iā€™ve tried for the host name. The user and password match whatā€™s in the config folder, but it still doesnā€™t want to let me in.

Test your database login credentials using Windows Command Prompt

Open the Windows Command Prompt or Windows PowerShell and use the syntax below to connect to MariaDB or MySQL:

mysql -u [username] -p

Replace [username] with the database username for your SuiteCRM installation.

This will tell you whether or not your login credentials for MySQL / MariaDBare are corrent and working, or not.

Post back your results of the command.