codeigniter 3数据库与第三方数据库的连接 [英] codeigniter 3 database connection with third party Database
问题描述
我正在尝试使用Codeigniter 3连接数据库,但是我面临这个问题,请任何人帮助.
I am trying to connect database using codeigniter 3 but i am facing this issue anybody please help.
遇到PHP错误严重性:警告消息: mysqli :: real_connect():(HY000/2005):未知的MySQL服务器主机 'pd8344-001.privatesql'(2)文件名:mysqli/mysqli_driver.php行 编号:202回溯:文件:/var/www/html/importdb/index.php行: 292功能:require_once
A PHP Error was encountered Severity: Warning Message: mysqli::real_connect(): (HY000/2005): Unknown MySQL server host 'pd8344-001.privatesql' (2) Filename: mysqli/mysqli_driver.php Line Number: 202 Backtrace: File: /var/www/html/importdb/index.php Line: 292 Function: require_once
还有
发生数据库错误,无法连接到数据库服务器 使用提供的设置.文件名:core/CodeIgniter.php行 数量:500
A Database Error Occurred Unable to connect to your database server using the provided settings. Filename: core/CodeIgniter.php Line Number: 500
这是我在配置文件中的数据库设置.
here is my db setting in config file.
$db['default'] = array(
'dsn' => '',
'hostname' => 'pd8344-001.privatesql',
'port' => '3306',
'username' => '****',
'password' => '****',
'database' => 'db_name',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => TRUE,
'db_debug' => TRUE,//(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
);
推荐答案
将数据库配置文件中的主机名设置为数据库服务器的实际主机名,然后它将按预期工作.
Set the hostname in your database config file to the actual hostname of the database server and it should then work as expected.
有效的主机名是域或IP.我希望看到的不是pd8344-001.privatesql
,而是类似的pd8344-001.privatesql.com
.
A valid hostname is either a domain, or IP. Rather than pd8344-001.privatesql
I would expect to see something more like pd8344-001.privatesql.com
for example.
如果在查找主机名时遇到麻烦,并且主机提供了phpMyAdmin界面,请登录到phpMyAdmin帐户并复制当前URL,并删除(包括)"/phpMyAdmin"之后的所有内容.
If you are having trouble finding the hostname and your host provides a phpMyAdmin interface, log into your phpMyAdmin account and copy the current URL with everything after (and including) "/phpMyAdmin" removed.
例如
pd8344-001.privatesql.com/phpMyAdmin?sess=213123123123&stuff=21314123123&more=sadhfasdjhgfasd
你应该得到
pd8344-001.privatesql.com
这篇关于codeigniter 3数据库与第三方数据库的连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!