Autocommit

By default, autocommit is ON, which means that all individual statements are committed as soon as they are executed unless they are in a BEGIN...COMMIT block. If autocommit is OFF, you need to explicitly issue a COMMIT statement to commit a transaction. To disable it, execute:

mysql> SET autocommit=0;

DDL statements, such as CREATE or DROP for databases and CREATE, DROP, or ALTER for tables or stored routines cannot be rolled back.

There are certain statements such as DDLs, LOAD DATA INFILE, ANALYZE TABLE, replication-related statements and so on that cause implicit COMMIT. For more details on these statements, refer https://dev.mysql.com/doc/refman/8.0/en/implicit-commit.html.

Get MySQL 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.