MySQL: access denied for user: (Using password: YES) June 30, 2005
Posted by javafoo in javanotes, jdbc, mysql.trackback
More experimenting with struts. So I got ambitious, downloaded MySQL and tried to wire a database into my simple struts app. Setting up MySQL was a breeze, although it was my first time, except that some time was wasted googling for user account creation etc.
So, I set up a datasource in Tomcat, which could be looked up by JNDI. I added this in server.xml.
But was getting errors with Context.lookup, indicating there was no “java:comp/env/jdbc” in the Context. Realized I forgot to add the resource-ref in my web descriptor.
This done, I was getting a different error.
Access denied for user ‘blah’: (Using password: YES).
What the …, I didn’t set the password as YES, what the heck was going on?
So googled again (one of these days, when someone asks me what tools, IDE I use for development, I will be sure to add ‘Google’ in there, in fact this should come integrated with the IDE, any Exception or Error message should be linked to Google search), anyway I digress.
So this seems to be a common problem. I tweak the user account a bit in MySQL, apparently the host shouldn’t be set as ‘%’, you are better off setting it to ‘localhost’. I also deleted the default user account ”, which is an empty string. So either of these fixed it for me and I am on my way.
Since I am seeing a lot of searches to this post and one of the commentors (Tyler) rightfully indicates that: The “YES” doesn’t mean that you are using the password “Yes” it simply means “Yes” you are using a password. If the password was blank it would have said “No”
That’s what I thought the issue was to start with (that somehow the password was set to ‘Yes’) or atleast that’s what the MySQL message led me to believe, but later when I tweaked the User Account to set the host, I realized what it was trying to tell me.
Thanks for helping out!
It would be cool if you said HOW to tweak the user account
Please Email me at MRSHarff@gmail.com
Thank you for this. I was about to give up on my phpbb3 install. I’m sure you figured this out by now Bale but you use something like phpMyAdmin to access it.
The “YES” doesn’t mean that you are using the password “Yes” it simply mean “Yes” you are using a password. If the password was blank it might say “No”
what?
francisco.good@hotmail.com
The problem is the host shouldn’t be ‘%’.
Set it to ‘localhost’. Problem solved.
Wow thanks so much for posting this. I’ve been banging my head for about an hour to get this working. I have no idea why using % does not allow localhost, but after changing it to be ‘localhost’, I’m able to connect.
And for those asking *how* to change it, I did it by connecting to the ‘mysql’ database and then running:
update user set Host=’localhost’ where User=’myUserName’
[...] via the command line client and via ColdFusion. Finally after some googling I came across this blog post suggesting to change the privilege details to allow connecting from ‘localhost’ instead [...]
What should you set the host to if you want it to connect from any external IP, and not limit it to just one permitted IP?
Pls I’m experiencing a serious sql problem… i changed the mysql password then did some changes then afterwards the site would nt open, it keeps saying…..
Access denied for user ‘v_root’@'cgi0603.int.bizland.net’ (using password: YES) even when i changed the password to blank… pls help!
Your major failing Gaxton
Your usernaame your entering is wrong
Its a vroot error
is it configuration problem or permission issue?
On a new installation of MySQL, phpMySQL shows under privileges there is a denial of access for ‘any user’ on % for usage privileges. This seems to stop any user matching. Delete these and users can access if they have only specific database access, or create a user that does not match exactly eg on localhost, then they can access. Reason ?