How to avoid DROP TABLE for a specific MySQL table

Posted on

Question :

I have used a WordPress plugin that for some unknown reason is always deleting a database table (cerber_files).

The plugin’s author is not giving support for this issue.

I think in order to solve this, there would be some option that would prevent DROP TABLE from being executed ONLY FOR THIS TABLE.

I’ve researched a lot but found no solution that worked for this issue.

Any idea?

Answer :

prevent DROP TABLE from being executed ONLY FOR THIS TABLE

But dropping some another table in the same database must be available?

If so the task cannot be solved using MySQL privilege system. Because some privilege granted to or revoked from some object affects on all its subobjects. Revoking DROP on some database revokes it for all tables in this database. No separate table privilege.

But the task can be solved using FOREIGN KEY subsystem.

Create some fake table. Set some field in this table as referenced to the table in question. And server will forbid your table drop until this fake table (or FK from it to your table) drop.

Leave a Reply

Your email address will not be published. Required fields are marked *