Sql statement, transaction rollback rollback does not take effect

sql transaction rollback (rollback) does not take effect.

mysql version 5.7.24, macOS10.14, sets autocommit to OFF does not take effect,

change the num=5, of On The Road to 1, withdraw the transaction, do not take effect, why is num or 1?

< table > < thead > < tr > < th > mysql > select name,num from book; < / th > < / tr > < / thead > < tbody > < tr > < td > name < / td > < td > num < / td > < / tr > < tr > < td > On The Road < / td > < td > 5 < / td > < / tr > < tr > < td > Effective Java < / td > < td > 1 < / td > < / tr > < tr > < td > the body has not forgotten < / td > < td > 1 < / td > < / tr > < / tbody > < / table >

3 rows in set (0.00 sec)

mysql > begin;
Query OK, 0 rows affected (0.00 sec)

mysql > start transaction;
Query OK, 0 rows affected (0.00 sec)

mysql > update book set num=1 where name="On The Road";
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

< table > < thead > < tr > < th > mysql > select name,num from book; < / th > < / tr > < / thead > < tbody > < tr > < td > name < / td > < td > num < / td > < / tr > < tr > < td > On The Road < / td > < td > 1 < / td > < / tr > < tr > < td > Effective Java < / td > < td > 1 < / td > < / tr > < tr > < td > the body has not forgotten < / td > < td > 1 < / td > < / tr > < / tbody > < / table >

3 rows in set (0.00 sec)

mysql > rollback;
Query OK, 0 rows affected, 1 warning (0.00 sec)

< table > < thead > < tr > < th > mysql > select name,num from book; < / th > < / tr > < / thead > < tbody > < tr > < td > name < / td > < td > num < / td > < / tr > < tr > < td > On The Road < / td > < td > 1 < / td > < / tr > < tr > < td > Effective Java < / td > < td > 1 < / td > < / tr > < tr > < td > the body has not forgotten < / td > < td > 1 < / td > < / tr > < / tbody > < / table >

3 rows in set (0.00 sec)
you can"t even try again after setting autocommit to OFF.

< table > < thead > < tr > < th > mysql > show variables like "auto%"; < / th > < / tr > < / thead > < tbody > < tr > < td > Variable_name < / td > < td > Value < / td > < / tr > < tr > < td > auto_increment_increment < / td > < td > 1 < / td > < / tr > < tr > < td > auto_increment_offset < / td > < td > 1 < / td > < / tr > < tr > < td > autocommit < / td > < td > OFF < / td > < / tr > < tr > < td > automatic_sp_privileges < / td > < td > ON < / td > < / tr > < / tbody > < / table >

4 rows in set (0.00 sec)

what result do you expect? What is the error message actually seen?

Mar.17,2022

the engine of your book table should be that MyISAM,MyISAM engine table does not support transactions, so it does not support rolling back


show create table book\ G


the search engine that builds the table is Innodb,
final solution: rollback takes effect after quitting mysql, reconnection, (a little inexplicable)

Menu