CodeIgniter Forums
Unable to connect to your database server using the provided settings. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Unable to connect to your database server using the provided settings. (/showthread.php?tid=79237)



Unable to connect to your database server using the provided settings. - ness-sg - 05-16-2021

A Database Error Occurred
Unable to connect to your database server using the provided settings.
Filename: core/CodeIgniter.php
Line Number: 517



i have this error on my website can anyone help me and it was working correctly before

thanks


RE: Unable to connect to your database server using the provided settings. - includebeer - 05-16-2021

The reason is right there on the second line: Unable to connect to your database server using the provided settings.
Try connecting to your database with something like PhpMyAdmin, using the same user/password you have in your configuration.
The database may be unavailable at the moment (down), maybe the password has expired and you are required to change it. There may be several reasons for this to happen.


RE: Unable to connect to your database server using the provided settings. - ness-sg - 05-16-2021

(05-16-2021, 06:11 AM)includebeer Wrote: The reason is right there on the second line: Unable to connect to your database server using the provided settings.
Try connecting to your database with something like PhpMyAdmin, using the same user/password you have in your configuration.
The database may be unavailable at the moment (down), maybe the password has expired and you are required to change it. There may be several reasons for this to happen.



i check all what i need to do now to solve this problem


RE: Unable to connect to your database server using the provided settings. - includebeer - 05-16-2021

What have you done so far? We don't have a crystal ball, you need to give some informations...


RE: Unable to connect to your database server using the provided settings. - InsiteFX - 05-16-2021

Here is some test code to see if your login is correct.

PHP Code:
<?php
// Code to create the database

// Add your own username and password
$serverName "localhost";
$userName   "username";
$password   "password";

// Create the Database Connection
$connId mysqli_connect($serverName$userName$password);

// Check the Database Connection
if ($connId === false)
{
    exit("ERROR: Could not connect. " mysqli_connect_error());


// Create the Database
// Add your datya
$sql "CREATE DATABASE yourDatabaseName";

// Check that the Database was created
if (mysqli_query($connId$sql))
{
    echo "Database created successfully";
}
else
{
    echo "ERROR: Creating Database. " mysqli_error($connId);
}

// Close the Connection
mysqli_close($connId);

?>



RE: Unable to connect to your database server using the provided settings. - wdeda - 05-16-2021

Did you change anything in the codeigniter.php file in /system/core?
Because according to the message, if you are using version 3.1.1, line 517 has no relation to databases:

PHP Code:
/* <== line 510
 * ------------------------------------------------------
 *  Instantiate the requested controller
 * ------------------------------------------------------
 */
 // Mark a start point so we can benchmark the controller
 
$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_start');
// <== line 517
 
$CI = new $class(); // <== line 518

/*