http://www.androidren.com/index.php?qa=211&qa_1=warning-mysql_connect-access-denied-root%40- Localhost-password
The code might be written like this:
//to make a connection with database$conn=mysql_connect("localhost", "Root", "Password") or die(Mysql_error());
In some cases, you can fix this by changing it to the following:
$conn = mysql_connect (" localhost "," root ")
 OR  $conn = mysql_connect (" localhost "," root "," ")
但是,有些情况下它的根本原因是你的当前数据库的用户没有获得多数据库访问的授权。
其实,最多的原因可能是你的数据库没有起来。O(∩_∩)O哈哈~
解决方法是你启动数据库。
The performance in this case is:
1. Under the command line:
forlong401:documents forlong401$ sudo mysql--user=root-p
Enter Password:
ERROR 2002 (HY000): Can ' t connect to local MySQL server through socket '/tmp/mysql.sock ' (2)
2. On the browser:
Deprecated: mysql_connect (): The MySQL extension is Deprecated and would be removed in the Future:use mysqli or P Do instead in /library/webserver/documents/qa/qa-include/qa-db.phpon line
Warning: mysql_connect (): Access denied for user ' root ' @ ' localhost ' (using Password:yes) in /library/webser ver/documents/qa/qa-include/qa-db.php on line
Could not establish database connection. Please check the username, password and hostname with the config file, and if necessary set up the appropriate MySQL user an D privileges.
3. On the phpMyAdmin:
#2002 cannot log on to the MySQL server
Warning:mysql_connect (): Access denied for user ' root ' @ ' localhost ' (using Password:yes)