Tag: autocommit

MySQL 全局禁用autocommit

mysql默认开启auto commit,我们可以通过系统变量控制来动态控制session级别autocommit,如何从全局禁用autocommit呢,也许有时候我们不想让mysql自动提交。 mysql有一个Cmd-Line&Option file&System Var可以帮助我们实现这样的功能,它就是init_connect。 这个参数用来定义每个session建立时自动执行的query。 A string to be executed by the server for each client that connects. The string consists of one or more SQL statements. To specify multiple statements, separate them by semicolon characters.A string to be executed by the server for each client that connects. The string consists of one or more SQL statements. To specify multiple statements, separate them by semicolon characters. 利用这个变量,可以通过如下方式禁用autocommit: way1:mysql>SET GLOBAL init_connect=’SET autocommit=0′; way2:在初始化参数文件中设置 [mysqld] init_connect=’SET autocommit=0′ way3: 启动mysql时带上命令行参数–init_connect=’SET autocommit=0′ 当然这个参数的设置对拥有super权限的用户是无效的,具体说明…

Read More »