dongwen3437 2019-08-15 06:34
浏览 188

SQLSTATE [HY000] [2002]连接到Amazon RDS时没有此类文件或目录

I'm hosting my web application to AWS using Amazon RDS MySQL for the database and Amazon EC2 for the server.

I have changed the database config (I'm using CodeIgniter) like this:

$db['default'] = array(
    'dsn'   => '',
    'hostname' => 'mysql:hostname=my-rds-endpoint.us-east-1.rds.amazonaws.com; dbname=go-edang; charset=utf8;',
    'username' => 'my-username',
    'password' => 'my-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
);

When I access the URL by using the DNS from my EC2 instance, it goes like this:

SQLSTATE[HY000] [2002] No such file or directory

Filename: controllers/Login.php

Line Number: 7

Is there any file or line that I should change? Or what is the correct way? Thank you.

  • 写回答

1条回答 默认 最新

  • doume1301 2019-08-15 11:02
    关注

    Try to use this config :

    $db['default'] = array(
        'dsn'   => 'mysql:hostname=my-rds-endpoint.us-east-1.rds.amazonaws.com; dbname=go-edang; charset=utf8;', 
        'hostname' => 'localhost',
        'username' => 'my-username',
        'password' => 'my-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
    );
    
    评论

报告相同问题?

悬赏问题

  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作