I have phpMyAdmin running with MAMP, and I am finding it impossible to use mysql_connect().
$_db_connect = mysql_connect("root", "localhost");
Produces an error in php_error.log: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Access denied for user
'root'@'localhost' (using password: NO) in /....../common.lib.php on line 19
I've checked out the privileges:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*81F5E21E35407D884A6CD4A731AEBFB6AF209E1B' WITH GRANT OPTION
GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION
and I am simply stumped. I've created new users with passwords just to get the same result. Strangely it always says (using password: NO
), even when I attempt to connect as a user witha password:
$_db_connect = mysql_connect(MYSQL_HOST, MYSQL_USERNAME, MYSQL_PASSWORD);
Any advice is welcomed. Thanks!
That error message for dummies:
Access denied for user 'root'@'localhost' (using password: NO)
It has three parts, each of it contains important information. Let's see:
So now on with the privileges you have:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost'
IDENTIFIED BY PASSWORD '*81F5E21E35407D884A6CD4A731AEBFB6AF209E1B'
WITH GRANT OPTION
GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION
It basically says, that the user 'root'@'localhost'
needs to use a password to get access. As the error message tells you, you are not using a password. So that is likely to be the cause of the error, the password is missing.
Add the password and try again.