Reputation: 11673
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?
Upvotes: 1
Views: 2862
Reputation: 12850
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...
Upvotes: 1
Reputation: 76567
You're connecting with the wrong password: Reset the password
or more likely: you don't have privileges to connect from localhost. Run the command:
GRANT ALL PRIVILEGES ON *.* TO 'root'@localhost WITH GRANT OPTION;
Test to see if you can connect.
Never do: GRANT ALL PRIVILEGES ON *.* TO 'root'@% WITH GRANT OPTION;
Because that will put your database server at risk from remote login attempts.
Upvotes: 1
Reputation: 12437
Maybe u are running mysql on a port other than the default port.
If it is the case use this:
mysql_connect('localhost:PORT', 'root', 'exobytes15')
Upvotes: 0
Reputation: 9148
Make sure you have that your database is running, and that the user has access to it.
You can use either use the plain old mysql commandline client for this or phpmyadmin if your wamp stack has that installed.
Upvotes: 1