我正在使用codeigniter 3.0,我正在尝试连接到远程数据库。我可以使用远程mysql用户从我的个人电脑成功连接。但是,当我把我的linux cpanel主机上的网站置于生产模式时,它无法连接。这种类型的连接与本地连接有任何已知问题吗?
我的webhost是linux(cpanel),我的数据库是mysql,存在于windows vps中。
这是我的连接信息:
$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;
这在开发中非常有效我使用IP作为主机名,而我在vps上的mysql用户启用了远程连接。
答案 0 :(得分:0)
在 linux base server 中,它使用localhost
作为主机名。但在 Windows服务器中有一个IP地址
$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