Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent mySql from changing specific rows

I'm using mysqldumb command to export/import a database (syncing between two machines). It works well, but I have a couple of rows that I don't want to be changed when importing the dumbed mysql file.

I know I can change the rows after restoring the file, but I wanted to know if a solution to prevent (a user) from changing some rows is possible.

like image 502
Omar Abid Avatar asked May 01 '26 04:05

Omar Abid


2 Answers

You could create an after trigger that resets the data back to its original state if it matches certain criteria.

like image 157
Derek Kromm Avatar answered May 04 '26 03:05

Derek Kromm


I assume you can identify those rows unequivocally. You could write a simple script that removes those lines and executes mysqldump; for example, if you use Linux:

cat filename.txt | grep -v "line you want to exclude" > newfile_without_the_line_u_want_to_exclude.txt

If it's always the same line number you could use sed, etc.

like image 25
Icarus Avatar answered May 04 '26 03:05

Icarus