Refused connection to database in production but not local

478 views Asked by At

I am using codeigniter 3.0 and I am trying to connect to a remote data base. I can successfully connect from my personal pc using a remote mysql user. However when I put the site in production mode on my linux cpanel hosting it cannot connect. Are there any known issues with this type of connection versus a local one?

My webhost is linux (cpanel) and my database is mysql and lives on a windows vps.

Here's my connection info:

$db['default']['username'] = "root";
$db['default']['password'] = "mysql";
$db['default']['database'] = "cms";
$db['default']['hostname'] = "localhost";
$db['default']['dbdriver'] = "mysqli";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";

/**
 *
 * THIS IS YOUR GAME DATABASE CONENCTION INFO
 *
 **/
$db['conquer']['username'] = "root";
$db['conquer']['password'] = "mysql";
$db['conquer']['database'] = "cq";
$db['conquer']['hostname'] = "104.238.133.31:3306";
$db['conquer']['dbdriver'] = "mysqli";
$db['conquer']['dbprefix'] = "";
$db['conquer']['pconnect'] = FALSE;
$db['conquer']['db_debug'] = TRUE;
$db['conquer']['cache_on'] = FALSE;
$db['conquer']['cachedir'] = "";
$db['conquer']['char_set'] = "utf8";
$db['conquer']['dbcollat'] = "utf8_general_ci";

$active_group = "default";
$active_record = TRUE;

This works perfect in development I am using an IP for the host name and my mysql user on the vps has remote connections enabled.

1

There are 1 answers

0
Abdulla Nilam On

In linux base server it use localhost for host name. but in windows server there is an ip address

$db['default']['hostname'] = '';//change ip to here
$db['default']['username'] = '';//input relevant username
$db['default']['password'] = '';//input relevant PW
$db['default']['dbdriver'] = '';//input relevant Driver