Two ways MySQL prevents the delete command from deleting data

  • 2020-05-30 21:11:02
  • OfStack

Method 1
What I usually do is add a delete id field to the database,
Such as: isdel=1 so that the code deleted the field

Method 2
Directly restrict mysql deletion

When MySQL is started, add the parameter -U

-U, --safe-updates Only allow UPDATE and DELETE that uses keys.

Its role is to prevent the execution of delete without a conditional statement, and if where is not added, the statement will not be executed.

Related articles: