How to deal with PHP connection failure

Source: Internet
Author: User
In a hurry, PHP connection to the database failed. I downloaded an open source file. After I imported the database file, how can I not Connect to the database? 'connect & nbsp; failed: & nbsp; access & nbsp; denied & nbsp; for & nbsp; user & nbsp; 'root' @ 'loca urgent, urgent, PHP database connection failure
I downloaded an open-source file and imported the database file. Why can't I connect to the database?
'Connect failed: Access denied for user' root' @ 'localhost'
------ Solution --------------------
You have to find the source code and modify the password for connecting to the database.
------ Solution --------------------
Check whether the username or password is written incorrectly. And the user name has permissions ..
------ Solution --------------------

// Servername [server name]: "127.0.0.1: 3306"
// Sqlname [mysql User name]: "ncmail"
// Sqlpassword [mysql User password]: "ncmail"
// Database [mysql database]: "ncmail"
$ Connect = mysql_connect ("127.0.0.1: 3306", "ncmail", "ncmail ");
If (! $ Connect ){
Die ("server connection failed:". mysql_error ());
}
$ Conn = mysql_select_db ("ncmail", $ connect) or die ("database connection failed!
");
Mysql_query ("set names utf8 ");

------ Solution --------------------
You can see what the user name and password are when you install mysql, and then change it to your user name and password.
------ Solution --------------------
The user name permission is incorrect.
Simply put, your mysql account is incorrect.
------ Solution --------------------
Account and password do not match

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.