Reputation: 33644
I have the following error:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user 'root'@'%' to database 'GUEST_BOOK'
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
previously I have done:
GRANT ALL PRIVILEGES ON GUEST_BOOK.* TO 'root@%' IDENTIFIED BY 'D7n()st1234' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
FLUSH PRIVILEGES;
not sure why it is still giving me that permission error? Any idea?
Upvotes: 2
Views: 7320
Reputation: 8594
'root@%'
is different than 'root'@'%'
in SQL terms
Essentially writing 'root@%' probably created an entry for a user called 'root@%' and not a user named root who would be accessing via any means (%)
Update your grant statement to read
GRANT ALL PRIVILEGES ON GUEST_BOOK.* TO 'root'@'%' IDENTIFIED BY 'D7n()st1234' WITH GRANT OPTION;
Upvotes: 2