How can I be sure that a query was not executed?

For example, I try to execute

update `table` set `a`='b' 

and got the error 2006 server has gone away

  • If you're worried about this, use transactions.
    – ceejayoz
    Mar 6, 2019 at 23:03
  • SELECT COUNT(DISTINCT a), COUNT(*) FROM table; to determine current DISTINCT number of values in your a column and total row count Mar 10, 2019 at 19:19

2 Answers 2


Don't run the SQL statement :-)

If you want the mysql client to stop you running it, there is a --safe-updates aka --i-am-a-dummy option.

If you want the server to rollback, use innodb tables that provide transactional support.

For the error see gone away.


How can I be sure that a query was not executed?

It did execute and it broke your database in doing so!

As such, when you next start your database, it will perform an "Instance Recovery" and undo any changes that were not committed at the point the instance died.

Once that is complete then it will be as if the query never ran - the database will have "undone" everything that the query did (to it!).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.