CodeIgniter Forums

Full Version: problem cconnecting MYSQL
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm having problems getting CodeIgniter to connect to a remote DB.

My base system is as follows:
CentOS 7 running on AWS
Apache, PHP and MySQL Client Installed
Installed php-mysql
CodeIgniter 3.0.0 installed and working with pages not using DB.

Remote database:
Amazon RDS running MySQL (separate machine).

I can connect to the DB from the base system using MySQL command line.
When I try connecting to the DB through a CodeIgniter connector, I receive the error below.
I'm using the same parameters in database.php in CI as in MySQL command line (checked a few times)

Any ideas? Thanks.


Severity: Warning
Message: mysqli::real_connect(): (HY000/2003): Can't connect to MySQL server on 'hostname' (13)
Filename: mysqli/mysqli_driver.php
Line Number: 135
File: /var/www/html/application/controllers/Messages.php
Line: 72
Function: database
File: /var/www/html/index.php
Line: 292
Function: require_once

$db['default'] = array(
'dsn' => '',
'hostname' => 'hostname',
'username' => 'user',
'password' => 'pwd',
'database' => '',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
You will have to change hostname into your mysql server ip address

PHP Code:
$db['default'] = array(
'dsn' => '',
'hostname' => '',
'username' => 'user',
'password' => 'pwd',
'database' => 'YOURDATABASENAME',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE