Symptoms:
Codeigniter unable to connect to your database server using the provided settings Error
Check whether the database configuration is normal.
Solution Process:
Add the following at the end of config/database. php:CodeFor debugging.
1 Echo '<PRE>' ; 2 Print_r ( $ DB ['Default' ]); 3 Echo '</PRE>' ; 4 5 Echo 'Trying to connect to database :'. $ DB ['Default'] ['database' ]; 6 $ DBH = Mysql_connect 7 ( 8 $ DB ['Default'] ['hostname'], 9 $ DB ['Default'] ['username'], 10 $ DB ['Default'] ['Password' ]) 11 Or Die ('Cannot connect to the database because :'. Mysql_error ()); 12 Mysql_select_db ( $ DB ['Default'] ['database' ]); 13 14 Echo '<Br/> connected OK :' ; 15 Die ('File :'. _ File __ . '--> Line :'. _ Line __ );
After adding the code, visit the website again to view the debugging information and provide the solution at the end.
Solution:
(Depending on the problem, the method is different) the debugging information prompts that the database is locked, so you need to unlock it first.
Execute mysqladmin flush-hosts
You can.
Reference: http://stackoverflow.com/questions/7254049/codeigniter-unable-to-connect-to-your-database-server-using-the-provided-settin