我有以下错误:
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)
以前我做过:
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;
不确定为什么它仍然给我这个权限错误?有什么想法吗?
答案 0 :(得分:2)
'root@%'
与SQL术语中的'root'@'%'
不同
基本上写'root @%'可能为名为'root @%'的用户创建了一个条目,而不是通过任何方式访问的用户root(%)
更新您的授权声明以阅读
GRANT ALL PRIVILEGES ON GUEST_BOOK.* TO 'root'@'%' IDENTIFIED BY 'D7n()st1234' WITH GRANT OPTION;