用codeIgniter连接外部数据库 [英] connect external db with codeIgniter

查看:92
本文介绍了用codeIgniter连接外部数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是代码点火器的新手, 我试图与本地数据库连接,然后成功连接,但是在与外部数据库连接时,导致错误

i am new in code igniter, i tried to connect with local db then successfully connected,but while connecting with external db it resulting an error

A PHP Error was encountered

Severity: Warning

Message: mysqli::real_connect(): (HY000/2003): Can't connect to MySQL server on 'xxxxx.gridserver.com' (110)

Filename: mysqli/mysqli_driver.php

Line Number: 202

Backtrace:

File: /var/www/html/restapi/application/libraries/REST_Controller.php
Line: 375
Function: __construct

File: /var/www/html/restapi/application/controllers/Project.php
Line: 26
Function: __construct

File: /var/www/html/restapi/index.php
Line: 292
Function: require_once

我不熟悉mysql

我搜索了更多内容,但我不知道他们在说些什么, 外部数据库连接可以做什么

i searched more for it, but i have no idea what they speaking about it, is there anything to do for external db connecton

提前谢谢!

推荐答案

1.检查您的application/config/database.php

1.Check your application/config/database.php

$db['default'] = array(
    'dsn'   => '',
    'hostname' => 'localhost', // your database machine name, this could have localhost, ip address or domain name.
    'username' => 'yourmysluser',
    'password' => 'yourmysqlpassword',
    'database' => 'yourdb',
    'dbdriver' => 'mysqli',

  1. 检查您的mysql数据库,出于安全原因,默认情况下禁用对MySQL数据库服务器的远程访问.但是,有时您需要证明可以从家庭或Web服务器远程访问数据库服务器.您可以使用mysql控制台或phpmyadmin或依赖于主机的其他数据库工具启用远程mysql访问. 请参考:
  1. Check your mysql database, by default remote access to the MySQL database server is disabled for security reason. However, some time you nee to provie remote access to database server from home or a web server. You can enable remote mysql access with mysql console or phpmyadmin or another database tool dependent your host. refer to this :

启用远程MySQL连接:错误1045 (28000):拒绝用户访问

https://www.youtube.com/watch?v=xXOq9U9fzOo

这篇关于用codeIgniter连接外部数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆