Search code examples
phpmysqlwampmysql-error-1045

I'm trying to connect to a mysql database using PHP but it won't work


I've Installed mysql, php, apache using a wamp configuration Where to access localhost is would be http://localhost:81 the PHP script I'm using is

if(mysql_connect('localhost', 'root', 'exobytes15')) {
mysql_select_db('testDB');
}
else {
echo 'Could not Connect to the database';
 }

But this gives me the error

1045: Access denied for user 'root'@'localhost' (using password: YES)

What should I do to fix this problem?


Solution

  • Either you didn't grant root@localhost the necessary rights to access the database or you're providing the wrong password.

    Note : granting access to root@`%` does NOT grant access to root@localhost...