File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes How to prevent a user from dropping tables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to prevent a user from dropping tables" Watch "How to prevent a user from dropping tables" New topic
Author

How to prevent a user from dropping tables

Gilbert johnson
Ranch Hand

Joined: Jul 10, 2005
Posts: 45
Hello fellow ranchers

I need some information on how to grant/revoke privileges on mysql database.

Basically I want to create a user and grant him select,insert and update permissions on the database. This is the user with which I'm connecting from my web app to perform operations.

So I connect as root and create the database discountweb - then I'm using the following command

GRANT SELECT, INSERT, UPDATE ON discountweb.* TO 'discountweb'@'localhost' IDENTIFIED BY 'test123' WITH GRANT OPTION;

This works fine - but this user (discountweb) also has the option to drop any table.

Can anyone let me know - how to revoke the drop privilege for this user.

Thanks
Gilbert johnson
Ranch Hand

Joined: Jul 10, 2005
Posts: 45
And also this user is able to drop the whole database.

So he should not be able to drop tables or database.

Thanks
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36555
    
  16
REVOKE drop_database FROM user ON my_database; ?

Not sure of the exact syntax, but it will be something like that.
If that doesn't work, go through your database instructions and look for revoke.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to prevent a user from dropping tables
 
Similar Threads
noob question about jdbc
Problem with Connecting to mysql using java
An Oracle DBA question
Creating user in Oracle through JDBC
Hibernate: How to disable insert?