Getting error mysqli::real_connect(): (HY000/2002): No such file or directory when i try to access my project on live server

前端 未结 6 999
伪装坚强ぢ
伪装坚强ぢ 2020-12-02 00:49

i had uploaded my website to server and then i tried to access, but the code igniter returns me that error that i don\'t find any answer, why is this happening?

my c

6条回答
  •  無奈伤痛
    2020-12-02 01:21

    Same problem occurd with me, with AWS RDS MySQL. Looked various sources, but as of this thread, almost all lack of answer. While this answer helped me, tweak in mind to update hostnames at server. Access your SSH and follow the steps:

    cd /etc/
    sudo nano hosts
    

    Now, Appending here your hostnames: For example:

    127.0.0.1 localhost
    127.0.0.1 subdomain.domain.com [if cname redirected to endpoints]
    127.0.0.1 xxxxxxxx.xxxx.xxxxx.rds.amazonaws.com [Endpoints]
    

    and now, configuring config/database.php as follows:

    $active_group = 'default';
    $query_builder = TRUE;
    
    $db['default'] = array(
        'dsn'   => '',
        'hostname' => '35.150.12.345',
        'username' => 'user-name-here',
        'password' => 'password-here',
        'database' => 'database-name-here',
        'dbdriver' => 'mysqli',
        'dbprefix' => '',
        'pconnect' => FALSE,
        'db_debug' => TRUE,
        'cache_on' => FALSE,
        'cachedir' => '',
        'char_set' => 'utf8',
        'dbcollat' => 'utf8_general_ci',
        'swap_pre' => '',
        'encrypt' => FALSE,
        'compress' => FALSE,
        'stricton' => FALSE,
        'failover' => array(),
        'save_queries' => TRUE
    );
    

    where 35.150.12.345 is your IPv4 Public IP, located at ec2-dashboard > Network Interfaces > Description : RDSNetworkInterface >> IPv4 Public IP('35.150.12.345') there.

    Note: Please note that only IPV4 will work at 'hostname' option. hostname, cname, domains will output database connection error.

提交回复
热议问题