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
you have to set mysql port number which is by default 3306 check this in database.php
use either
'dbport' => '3306',
or
'hostname' => 'mysql.hostingprovider.com:3306',
Connect localhost with port solves the problem for me.
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost:3308', //Added port here
'username' => 'root',
'password' => '1234',
'database' => 'my_database',
'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
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With