Rollback not working in MySQL

By default, MySQL starts the session
for each new connection with
autocommit enabled,

You could set autocommit mode disable before running your query

SET autocommit=0;

ref:

Link 1

Link 2


You should be able to rollback your transaction as the table engine is InnoDB. enter image description here

Anyways here is the correct way to do transactions,

SET autocommit=0;
START TRANSACTION; 
Your Query here.
ROLLBACK;

and make sure that you are not using COMMIT after the Query which you need to rollback. Refer Table Engines and Transaction. And When a DB connection is created, it is in auto-commit mode by default. This means that each individual SQL statement is treated as a transaction and is automatically committed right after it is executed. So if you need to do transactions yourself, you must turn off the autocommit mode by AUTOCOMMIT = 0. Refer this link for more info.


Make sure you already do command

start transaction;  

before the query delete.

Tags:

Mysql