• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem cconnecting MYSQL

#1
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.

Andy

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
Backtrace:
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
);
Reply

#2
You will have to change hostname into your mysql server ip address

e.g
PHP Code:
$db['default'] = array(
    
'dsn' => '',
    
'hostname' => '127.255.255.255',
    
'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
); 
God Bless CI Contributors Smile
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.