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?

Roy Hinkley
  • 10,111
  • 21
  • 80
  • 120

1 Answers1

-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