Reputation: 49
I create a project in Codeigniter version 3.1.1. It's working fine on local. But when I upload it into the server then giving error:
A PHP Error was encountered
Severity: Warning
Message: mysqli::real_connect(): (HY000/1045): Access denied for user 'myprac_usr'@'localhost' (using password: YES)
Filename: mysqli/mysqli_driver.php
Line Number: 201
Backtrace:
File: /var/www/html/myproject/application/controllers/User.php
Line: 10
Function: __construct
File: /var/www/html/myproject/index.php
Line: 315
Function: require_once
$db['default'] = array(
'dsn' => '',
'hostname' => 'hostip',
'username' => 'mydbusername',
'password' => 'mydbpassword',
'database' => 'mydbusername',
'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
);
I have also changed the host name with "localhost" instead of host ip.
Mysql version- 5.6.27
PHP version- 5.5.36
Upvotes: 0
Views: 19776
Reputation: 1127
1st one check remote server mysql port -
telnet 182.122.33.44 3306
If successfully connected it will print mysql version & others
then add mysql port on your CI code -
'hostname' => '182.122.33.44:3306',
Upvotes: 1
Reputation: 401
Most Probably you have not provided the correct credentials for your database configuration.
Double check your username, password,hostname,
Upvotes: 1