CodeIgniter Forums
Error conecting to external DB - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: Error conecting to external DB (/thread-76756.html)



Error conecting to external DB - rav1971 - 06-16-2020

I have this error when iI try to connect to external DB:

Severity: Warning --> mysqli::real_connect(): (HY000/2002): Connection refused system/database/drivers/mysqli/mysqli_driver.php 202

I am sure credentials are Ok and if I use this code to check if I can connect:

PHP Code:
$servername "servername.com";
$username "username";
$password "password";
$database "database";

// Create connection
$conn mysqli_connect($servername$username$password$database);

// Check connection
if (!$conn) {
    die("Connection failed: " mysqli_connect_error());
}

echo 
"Connected successfully"

I always got "Connected successfully"

This is my configuration:


Quote:$db['mydb'] = array(
'dsn' => '',
'hostname' => 'servername.com',
'username' => 'username',
'password' => 'password',
'database' => 'database',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => TRUE, // or FALSE doesn't make difference
'db_debug' => '',
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);



Any advise?


RE: Error conecting to external DB - php_rocs - 06-17-2020

@ rav1971,

Have you looked up the error message? Also, when you said that you always got "Connected successfully" was your PHP and server versions and settings that same between the two systems? Did something change PHP, Mysql versions?