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