Codeigniter Unabletoconnecttoyourdatabaseserverusingtheprovidedsettings error solution

Source: Internet
Author: User
Codeigniter Unabletoconnecttoyourdatabaseserverusingtheprovidedsettings error solution

A few days ago, I said that Codeigniter encountered A Database Error Occurred Error. today I found the real cause of the problem: I have no permission to access the Database.

Error message:


Unable to connect to your database server using the provided settings
When searching for a database link, you can always find the answer with the premise that you already have the permission to access the database. at last, you can find the answer from the source.


Solution process:

Add the following code at the end of config/database. php for debugging.


Echo'
'; Print_r ($ db ['default']); echo'
'; Echo 'trying to connect to database :'. $ db ['default'] ['database']; $ dbh = mysql_connect ($ db ['default'] ['hostname'], $ db ['default'] ['username'], $ db ['default'] ['password']) or die ('cannot connect to the database because :'. mysql_error (); mysql_select_db ($ db ['default'] ['database']); echo'
Connected OK: '; die ('File:'. _ file _. '--> Line:'. _ LINE __);
When I access the website again, I am prompted that the server does not have the permission to access the database, and the server sets the access permission, everything is OK.


The lesson learned from this story is that what others have said may not be exactly correct, and it verifies the sentence "Seeing is believing ".

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.