0

I have to connect database from my domain example (www.test.com) to other project on localhost xampp thought codeigniter platform.

I have tried below code in aplication/config/database.php

Note: I have not mentioned exact host name, database, username & password for security reasons.

$db['default'] = array(
    'dsn'   => '',
    'hostname' => 'XXX.XX.XX.XXX:3306',
    'username' => '****_cs_user',
    'password' => '********',
    'database' => '****_case_study',
    'dbdriver' => 'mysqli',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'production'),
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);
Dharman
  • 30,962
  • 25
  • 85
  • 135

1 Answers1

0
  1. You need to ensure that this options are correctly filled:
 $db['default'] = array(
     'dsn'   => '',
     'hostname' => 'yourhostip',
     'username' => 'yourmysluser',
     'password' => 'yourmysqlpassword',
     'database' => 'yourdb',
     'dbdriver' => 'mysqli',
     'port'     => '3306'
     // Rest of options
  );

According to the Codeigniter documentation, you can separate the port from the hostname.

  1. You should make sure that in your server is activated the remote access, by default is disabled. Check this post to enable this feature.