Codeigniter: Connect to Amazon RDS SSL Database

I am having problems connecting to the RDS Amazons service from my Codeigniter application.

Settings in the database configuration:

$db['default']['ssl_set'] = TRUE; $db['default']['ssl_key'] = NULL; $db['default']['ssl_cert'] = NULL; $db['default']['ssl_ca'] = realpath('./application/third_party/mysql-ssl-ca-cert.pem'); $db['default']['ssl_capath'] = NULL; $db['default']['ssl_cipher'] = NULL; 

However, when I connect. I get a message:

Cannot select the specified database: Staging File name: ... \ system \ database \ DB_driver.php Line number: 140

Line 40 is shown here:

  // Select the DB... assuming a database name is specified in the config file if ($this->database != '') { if ( ! $this->db_select()) { log_message('error', 'Unable to select database: '.$this->database); if ($this->db_debug) { $this->display_error('db_unable_to_select', $this->database); // LINE 140 } return FALSE; } 

I made the following changes to get mysqli working with SSL:

I am surprised that he successfully connected, as he complains about choosing a database. Not sure where to go from here?

I am using PHP 5.3.8 on a windows machine.

Update

This turns into a mistake rather than a problem with my implementation. If I set $db['default']['db_debug'] to false . I no longer get this problem. However, I get link warnings:

 Severity: Warning Message: mysqli_real_escape_string() [function.mysqli-real-escape-string]: invalid object or resource mysqli Filename: mysqli/mysqli_driver.php Line Number: 346 

This means that there was an unsuccessful connection to the database via SSL.

Update 2

I am using XAMPP.

And I am using Codeingiter 2.0.2.

Update 3

My database configuration file:

 $db['default']['hostname'] = 'xxxx.us-east-1.rds.amazonaws.com'; $db['default']['username'] = 'xxxxx'; $db['default']['password'] = 'xxxx'; $db['default']['database'] = 'xxxx'; $db['default']['dbdriver'] = 'mysqli'; $db['default']['port'] = 3306; $db['default']['dbprefix'] = ''; $db['default']['pconnect'] = TRUE; $db['default']['db_debug'] = true; $db['default']['cache_on'] = FALSE; $db['default']['cachedir'] = ''; $db['default']['char_set'] = 'utf8'; $db['default']['dbcollat'] = 'utf8_general_ci'; $db['default']['swap_pre'] = ''; $db['default']['autoinit'] = TRUE; $db['default']['stricton'] = FALSE; $db['default']['ssl_set'] = true; $db['default']['ssl_key'] = NULL; $db['default']['ssl_cert'] = NULL; $db['default']['ssl_ca'] = realpath('./application/third_party/mysql-ssl-ca-cert.pem'); $db['default']['ssl_capath'] = NULL; $db['default']['ssl_cipher'] = NULL; 
+6
source share
1 answer
 $db['default']['port'] = 3306; 

Try adding this to your db configuration. mysql_real_connect() expects parameter 6 to be LONG int; intercepts an empty string.


Update

The function below line 140 in DB_Driver is where dbcollat ​​and charset are set. They will fall into real_escape in the driver and cause escape_error, if not correct.

Try

 $db['default']['dbcollat']=''; 

Or check that your db is encoded with what you have in your db configuration. those. if your db charset is latin1 and you are using utf-8, conn_id will be erroneous and mysqli_escape will overlap.

+5
source

Source: https://habr.com/ru/post/909781/


All Articles