1

whenever I am trying to connect phpMyadmin through php script it is showing some errors like 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?

2 Answers 2

2

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';
Sign up to request clarification or add additional context in comments.

1 Comment

Biggs is right. also, on a dev box you can use the root usename and password u specified during mysql installation. if you are not comfortable with CLI you can install link for web interface. you can also use tasksel for performing various tasks like installing AMP on linux box in one go.
0

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);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.