An Access denied
error can have many
causes. Often the problem is related to the MySQL accounts
that the server allows client programs to use when connecting.
See Section 5.5, “The MySQL Access Privilege System”, and
Section 5.5.7, “Causes of Access-Denied Errors”.
User Comments
I had this problem and discovered that the user's password became corrupted, using the root account I did an update and reset the user password to a know value.
Maybe obvious to some but
You need to connect to a database before anything will work. If you get errors like 'access denied xxx@localhost' it may be because you have not connected to a database yet.
Even though the service is running you can't do anything without first connecting to a database.
One way to do this, is open the 'MySQL Command line client' installed in Windows when you run the 'mysql-4.1.13-win32.zip' file
Click Start button then 'Programs' , 'MySQL', 'MySQL Server 4.1', 'MySQL Command line client'
If it asks for a password key it in, hopefully you remembered it when you installed the MySQL. If not rerun the wizard by clicking Start button,
'MySQL', 'MySQL Server 4.1', 'MySQL Server instance config wizard'
At the prompt MySQL> key in this
connect yourdatabasename
Such as
connect test
test is a sample database installed for you. It has no tables though. You can create a table by keying in this at the prompt
Create Table sample (ID int, FName char(20), LName char(20)); <<< don't forget the semicolon
Then add data to the sample table key this in at the prompt
Insert Into sample (ID, FName, LName) values (1, 'fred', 'flintstone');
If you don't put a semicolon at the end of a SQL line you will get a new -> each time you hit the Enter key.
PHP520, MYSQL5027, WinServer2003r2
i created a database with no tables
i created a user with no privileges (testuser,testpw,localhost)
<?php
$MYhostname="localhost"; $MYusername="testuser"; $MYpassword="testpw"; $MYdatabase="mysqlitest";
$MYlink=mysqli_connect($MYhostname, $MYusername, $MYpassword, $MYdatabase) or trigger_error(mysqli_connect_error(),E_USER_ERROR);
printf("Host information: %s\n", mysqli_get_host_info($MYlink));
mysqli_close($MYlink);
?>
This gave an Access Denied error.
But it works with mysql_connect() !!!!!!!!!!!!!
Solution: give the user a GLOBAL SELECT privilege
or create a table and give a SELECT priviledge to the table.
Hope this helps.
Add your own comment.