I trying to set "ALL PRIVILEGES" from Java on remote MySQL database test and user test . Here is snippet of my code:
Class.forName("com.mysql.jdbc.Driver");
Connection con = null;
con = (Connection) DriverManager.getConnection("jdbc:mysql://xx.xxx.xxx.xx:3306/?user=root&password=pswrd");
Statement st = con.createStatement();
int res = st.executeUpdate("GRANT ALL PRIVILEGES ON test.* TO 'test'@'%' IDENTIFIED BY '12345';");
Nothing extraordinary. All queries from root user work fine, but in this partucular case I'm getting error:
Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user 'root'@'%' to database 'test'
What did I do wrong?
UPDATE
Here's answer. So, the problem wasn't solved ...