Codeigniter unable to connect to your database server using the provided settings error Solution

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.