我使用PHP,Mysql和Codeignater版本3创建一个网站 . 然后在iPage上托管它 . 当我上传时,我在配置文件中进行了更改 .
$db['default'] = array(
'dsn' => '',
'hostname' => '66.96.147.118',
'username' => 'bit_root',
'password' => 'root',
'database' => 'bit_shilp',
'dbdriver' => 'mysqli',
'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
);
我使用codeignater版本3.在本地它工作得很好 . 但在现场网站上它会出错 .
请看这个链接http://bitshilp.com/BitShilp/index.php/home
它给出了这样的错误:
遇到PHP错误严重性:警告消息:mysqli :: real_connect():( HY000 / 2002):连接被拒绝文件名:mysqli / mysqli_driver.php行号:161 Backtrace:文件:/ hermes / bosnaweb13a / b2582 / ipg . bitshilpcom / BitShilp / application / controllers / Home.php行:7功能:__ construct文件:/hermes/bosnaweb13a/b2582/ipg.bitshilpcom/BitShilp/index.php行:292功能:require_once遇到PHP错误严重性:警告消息:无法修改标头信息 - 已经发送的标头(输出从/hermes/bosnaweb13a/b2582/ipg.bitshilpcom/BitShilp/system/core/Exceptions.php:272开始)文件名:core / Common.php行号:568 Backtrace:文件:/hermes/bosnaweb13a/b2582/ipg.bitshilpcom/BitShilp/application/controllers/Home.php行:7功能:__构造文件:/hermes/bosnaweb13a/b2582/ipg.bitshilpcom/BitShilp/index.php行:292功能:require_once
谢谢 .
3 回答
如果MySQL服务器启动并运行 - 那么这看起来像是一些传输(例如防火墙)问题 . 第一步是尝试下面的telnet命令 - 如果它显示错误,那么问题与PHP或MySQL无关:
(成功时会打印mysql版本的一些随机字符)
使用AWS RDS MySQL,我遇到了同样的问题 . 看了各种各样的消息来源,但截至本帖,几乎都缺乏答案 . 虽然this answer帮助了我,但请记住更新服务器上的主机名 . 访问您的SSH并按照以下步骤操作:
Now, Appending here your hostnames: 例如:
现在,按如下方式配置
config/database.php
:其中
35.150.12.345
是您的IPv4公共IP,位于ec2-dashboard > Network Interfaces > Description : RDSNetworkInterface >> IPv4 Public
IP('35.150.12.345')那里 .Note: Please note that only IPV4 will work at 'hostname' option. hostname, cname, domains will output database connection error.