我如何连接到其他服务器上的数据库,例如来自heroku上托管的pdo codeigniter项目的db4free.net

时间:2018-08-29 11:04:37

标签: codeigniter heroku

我正在尝试使用db4free.net上的外部mysql数据库在heroku上托管一个codeigniter项目。

我尽力而为,但我最后的努力看起来像这样

$db['mysql'] = array(
	'dsn'	=> 'mysql:hostname="db4free.net"; dbname=ravenstock',
	'hostname' => '',
	'username' => 'ravenstockadmin',
	'password' => '**************',
	'database' => '',
	'dbdriver' => 'pdo',
	'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
);

1 个答案:

答案 0 :(得分:0)

  

请尝试一下...

'hostname' => '45.113.122.253:3306',
'username' => 'your server username',
'password' => 'your server password',
'database' => 'server database name',
'dbdriver' => 'pdo',
'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