当对数据库进行操作的时候,会遇到root无操作权限问题。
一般会提示如下:
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103).......
Caused by: java.sql.BatchUpdateException: The user specified as a definer ('root'@'%') does not exist
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2007)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1443).........
要做的就是将所有sql权限赋予root。两个步骤即可解决:
1、 grant all privileges on *.* to root@"%" identified by ".";
Query OK, 0 rows affected (0.11 sec)
2、flush privileges;
Query OK, 0 rows affected (0.08 sec)
具体操作见下图:
权限已经授权完毕。