Tag: grant

使用java在mysql中创建用户

在以root身份登录后的MySQL命令行客户端中,我键入: connect mydb; grant all privileges on mydb.* to ‘admin’@’localhost’ identified by ‘pass’; 现在在Java中 ,我使用admin userid使用驱动程序成功连接到数据库。 Statement put=connect.createStatement(); //**WORKS succesfully** put.execute(“insert into mydb.emp values(100,joe)”); //**does NOT work** put.execute(“grant all privileges on mydb.* to ‘john’@’localhost’ identified by ‘pass'”); 为什么insert命令有效但grant命令永远不能通过Java工作? 请帮忙。