Codeigniter error when trying to connect to database using mysqli

后端 未结 10 860
陌清茗
陌清茗 2020-12-21 09:39

I am getting Following error in my CodeIgniter application which is live on server.

Here is the output of the error:

A PHP Error was encounte

相关标签:
10条回答
  • 2020-12-21 09:49

    u can add new user and pass and give it all privileges, like below:

    CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
    GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'localhost';
    FLUSH PRIVILEGES;
    

    then, u should update your config.php file, with new user and pass.

    0 讨论(0)
  • 2020-12-21 09:50

    Do the following:

    1. In applications/config/database.php, add dbport => '3306', to the default array $db['default'] = array();
    2. In system/database/DB_driver.php, change public $port = ''; to public $port = '3306';
    0 讨论(0)
  • 2020-12-21 09:51
    $db['default'] = array(
        'dsn'   => '',
        'hostname' => 'localhost',
        'username' => 'root',
        'password' => '',
        'database' => 'xxx',
        '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
    );
    
    0 讨论(0)
  • 2020-12-21 09:58

    You can edit your server's php.ini file to define the port that CodeIgniter will use by default.

    C:\wamp64\bin\apache\apache2.4.41\bin\php.ini

    Default port number for mysqli_connect().

    mysqli.default_port = 3308

    0 讨论(0)
  • 2020-12-21 10:00

    Try to use the plain password with no special characters, below is the example:

    $db['default'] = array(
        'dsn'   => '',
        'hostname' => 'localhost',
        'username' => 'password',
        'password' => 'Mynewpass@756',
        'database' => 'database_name',
    );
    
    0 讨论(0)
  • 2020-12-21 10:08

    Try to set config/database.php 'username' => 'xxx' to 'username' => 'root' without any password.

    $db['default'] = array( 
    'dsn' => '',
    'hostname' => 'localhost',
    'username' => 'root',
    'password' => '',
    
    0 讨论(0)
提交回复
热议问题