Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL Lock A Table

Tags:

mysql

locking

How do you lock a table in MySQL so that you cannot edit or drop it no matter what unless you unlock it?

like image 449
NoodleOfDeath Avatar asked Dec 29 '22 01:12

NoodleOfDeath


1 Answers

"Locking" a table generally means restricting access to the data in the table by other processes while the data is being edited. To secure a table so that it can't be altered or dropped, I think the best solution would be to change the permissions of the table, removing DROP, UPDATE, INSERT and whatever other permissions you want to restrict, for that specific table.

REVOKE DROP, INSERT, TRUNCATE ON database.table FOR 'user'@'host';
like image 167
Wige Avatar answered Dec 30 '22 15:12

Wige