Codeigniter error when trying to connect to databa

2020-02-15 01:37发布

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 encountered

Severity: Warning

Message: mysqli::real_connect(): (HY000/1044): Access denied for user 'xxx'@'localhost' to database 'xxx'

Filename: mysqli/mysqli_driver.php

Line Number: 161

Backtrace:

File: /home/arya123/public_html/application/controllers/Home.php Line: 7 Function: __construct

File: /home/arya123/public_html/index.php Line: 292 Function: require_once

8条回答
家丑人穷心不美
2楼-- · 2020-02-15 02:08
$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
);
查看更多
该账号已被封号
3楼-- · 2020-02-15 02:10

I had the same trouble. Since I use xampp and I was running my codeigniter app locally, the problem at the end I solved it by remplacing: 'hostname' => 'localhost ' by 'hostname' => '127.0.0.1:33065' the :33065 is the port assigned by default by xampp for phpmyadmin. If you are running your proyect in the xampp default options, changing this, should be enough (hopefully). But if you don´t, I guess, you can search which port you are using for the database conection, and add it to your hostname with ":" (if you are not sure which port you are using, you always can see in your D.B. administration tool -phpmyadmin or the one you are using- on the options, which port is taking).

查看更多
登录 后发表回答