开发者

Mysql database connection error

whenever I am trying to connect phpMyadmin through php script it is showing some errors li开发者_C百科ke this Warning: mysql_connect(): Access denied for user 'www-data'@'localhost' (using password: NO) I am using ubuntu 11.04.So can you tell me how to solve this?


This error simply means that your connection information is incorrect. You are trying to connect to the MySQL database using the username "www-data@localhost" with no password. Check your MySQL permissions to see what you need to do. Either this login needs a password or this login is not specified as being permitted to access the data.

To check what permissions you have for that user, run this MySQL script:

SELECT * FROM user WHERE user='www-data';

To add rights to that user (if they are missing), run this script:

GRANT SELECT ON database.* TO 'www-data'@'localhost';


This works for me.

$dbhost = 'localhost';
$dbuser = 'www-data';
$dbpass = '<PUT PASSWORD FOR  HERE>';
$dbname = '<YOUR DATABASE NAME>';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Could not connect: ' . mysql_error());
mysql_select_db($dbname);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜