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.

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
);