3

I have a created user in my MySQL database:

CREATE USER 'user'@'host' IDENTIFIED BY 'password';

I have granted that user full privileges:

GRANT ALL ON *.* to 'user'@'host';

Echoing the grant:

GRANT ALL PRIVILEGES ON *.* TO 'user'@'host' IDENTIFIED BY PASSWORD '*03FFC888F82E921D8CA360925A8F443CF326DE89'

I can connect from MySQL workbench using this login credential w/o any issues and execute queries. And it's running on the same machine the web application is running on. MySQL instance is running on another computer in the same local network.

However, when I try to use the same credentials from my web application running in Tomcat7 under Eclipse I receive the error. Please advise.

Note: As of last night, the web application was able to connect just fine. With nothing changing (that I am aware of - I am only one working on this), this morning I could not connect.

RESOLVED: I added the user with grants using the IP address for the host for the local machine. I am not sure what changed on the server, but now I am able to connect again.

Would someone possibly be able to explain this change, and with it why I am now required to use the IP address when previously the local host name was sufficient?

5
  • Check your MySQL server log for error messages. Jan 28, 2014 at 16:52
  • Is the web application running from a different server to Workbench?
    – dwjv
    Jan 28, 2014 at 16:52
  • is your web app on a different host?
    – Hugh Jones
    Jan 28, 2014 at 16:52
  • Nothing in the logs that I can see with respect to this. I am reviewing the logs in /var/logs... Jan 28, 2014 at 16:55
  • A little stumped if it's the same machine. Double check it's not a typo and maybe try creating the user as 'user'@'%' just to confirm. Once connected issuing SHOW PROCESSLIST will identify where it's come from.
    – dwjv
    Jan 28, 2014 at 17:01

1 Answer 1

-2

Make sure you are using the appropriate hostname, and you're accessing from that host, the user can't connect from another host.

To give permission you must put the password unencrypted.

Example

GRANT ALL PRIVILEGES ON test. * TO 'root' @ 'localhost' 

      IDENTIFIED BY 'goodsecret'; 

Also must be the same password when you create the user.

Here How adding users to MySQL

Note: For more information on GRANT here is the documentation.

Hope this helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.