MySQL Commit and Rollback:
(1) The COMMIT Statement commits changes to the database, and the ROLLBACK Statement undoes any changes made by the statement and returns the database to the state it was in when the transaction began.
(2) In MySQL, on the top click on the Edit button and then select Preferences.
(3) Under SQL Execution, Untick “New connections use auto commit mode” and then click ok. After that close MySQL Workbench and then again open it so that necessary changes should take place. We disable the auto commit so that we can check the Rollback query in MySQL.
(4) Example of MySQL COMMIT: Written content in the below image shows how you have to run a query.
(5) Example of MySQL ROLLBACK: For running the query same procedure is followed as shown in the above image.
(6) Below Image shows an example of No ROLLBACK:
(7) Now we use DELETE Command as shown below.
In the above image, if we use ROLLBACK after that the deleted id will reappear but if we use COMMIT then ROLLBACK does not work as shown below.