views:

35

answers:

4

Is there a way to configure a mysql table so that writting and reading is possible but not deleting ?

Exampe is : a table that contains many log that are legally important and that must never be deleted !

+2  A: 

Revoke the delete privilege from all users for that table.

Zed
It's worth mentioning that UPDATE of a row is still possible though
Paul Dixon
sounds to be the good way to do so :) thx for answering
Amo__
A: 

You could do as he says below or... What you could do, is give users 'roles' in number form, then pass this number to a script which would remove the row... but if the passed number is below a certain 'minimum role expectation' then they are denied access to the script?

tarnfeld
yes but human errors are still possible in my application code with this solution :) thx for answering btw
Amo__
+3  A: 

You would just grant the INSERT and SELECT privileges on the table in question (this prevents the possibility of a row being changed)

GRANT INSERT,SELECT ON mydb.mytable 
TO secureduser@localhost 
IDENTIFIED BY 'password';

From this you would go on to add wider permissions to the other tables in the database for this user.

Also, check out the Archive Storage Engine, which is custom designed for this kind of audit-trail application.

Paul Dixon
+1  A: 

Another option is to use the Archive storage engine. It only allows insertion, no updates or deletes (from anyone - even a privileged account)

Brenton Alker