Hi I am using MAMP and Codeigniter. The Codeigniter version is 2.x I built an application on Linux [LAMP] now I want to move the application to MAC Book. When I Open the Localhost it shows me error of :
A Database Error Occurred
Unable to connect to your database server using the provided settings.
Filename: core/Loader.php
Line Number: 347
Now what could be the reason? My Credentials are correct but maybe I am trying to access it in wrong manner?
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = '';
$db['default']['database'] = 'biz_prov';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
In LAMP I had to do localhost/project but here I Have localhost:8888/projectname can this be the possible reason?
There could be couple of reasons for this issue:
dbdriver: Replacing mysql with mysqli worked for me, if doesn't work, you can also try with sqlsrv
$db['default']['dbdriver'] = 'mysqli'; // mysqli for mac,
$db['default']['dbdriver'] = 'mysql'; //mysql for windows
pconnect: You may need to set to FALSE
$db['default']['pconnect'] = TRUE;
And,Credentials. Do verify your username and password, cuz it gives the same error when credentials doesn't match.
One thing at a time, You may not need to modify all, but it won't hurt to try when something doesn't work :)
Sample for reference:
$db['default']['hostname'] = 'localhost'; // try using ip or ip and port if needed(trying doesn't hurt).
$db['default']['username'] = '*****'; // provide your username
$db['default']['password'] = '*****'; // provide your password
$db['default']['database'] = 'storedb';
$db['default']['dbdriver'] = 'mysqli'; // mysqli for mac, mysql for windows
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;