1.测试环境 Windows Server 2008 r2+MySQL Community Server (GPL) 5.7.16 我是在Windows Server 2008 r2环境下进行测试。 点击(此处)折叠或打开
mysql> status -------------- mysql Ver 14.14 Distrib 5.7.16, for Win64 (x86_64)
Connection id: 2 Current database: Current user: root@localhost SSL: Not in use Using delimiter: ; Server version: 5.7.16 MySQL Community Server (GPL) Protocol version: 10 Connection: localhost via TCP/IP Server characterset: latin1 Db characterset: latin1 Client characterset: utf8 Conn. characterset: utf8 TCP port: 3306 Uptime: 9 min 5 sec
Threads: 1 Questions: 7 Slow queries: 0 Opens: 106 Flush tables: 1 Open tables: 99 Queries per second avg: 0.012 --------------
mysql> mysql> show global variables like '%commit%'; +-----------------------------------------+-------+ | Variable_name | Value | +-----------------------------------------+-------+ | autocommit | ON | | binlog_group_commit_sync_delay | 0 | | binlog_group_commit_sync_no_delay_count | 0 | | binlog_order_commits | ON | | innodb_api_bk_commit_interval | 5 | | innodb_commit_concurrency | 0 | | innodb_flush_log_at_trx_commit | 1 | | slave_preserve_commit_order | OFF | +-----------------------------------------+-------+ 8 rows in set, 1 warning (0.00 sec)
mysql> set autocommit=0; Query OK, 0 rows affected (0.00 sec) mysql> mysql> set global autocommit=0; Query OK, 0 rows affected (0.00 sec)
mysql> show global variables like '%commit%'; +-----------------------------------------+-------+ | Variable_name | Value | +-----------------------------------------+-------+ | autocommit | OFF | | binlog_group_commit_sync_delay | 0 | | binlog_group_commit_sync_no_delay_count | 0 | | binlog_order_commits | ON | | innodb_api_bk_commit_interval | 5 | | innodb_commit_concurrency | 0 | | innodb_flush_log_at_trx_commit | 1 | | slave_preserve_commit_order | OFF | +-----------------------------------------+-------+ 8 rows in set, 1 warning (0.02 sec)
mysql>
接下来,我们重启数据库,发现autocommit参数已经恢复默认值。 点击(此处)折叠或打开
E:/mysql-5.7.16-winx64/bin>net stop mysql MySQL 服务正在停止. MySQL 服务已成功停止。
E:/mysql-5.7.16-winx64/bin>net start mysql MySQL 服务正在启动 . MySQL 服务已经启动成功。
E:/mysql-5.7.16-winx64/bin>mysql -u root -proot mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 2 Server version: 5.7.16 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.
mysql> mysql> show global variables like '%commit%'; +-----------------------------------------+-------+ | Variable_name | Value | +-----------------------------------------+-------+ | autocommit | ON | | binlog_group_commit_sync_delay | 0 | | binlog_group_commit_sync_no_delay_count | 0 | | binlog_order_commits | ON | | innodb_api_bk_commit_interval | 5 | | innodb_commit_concurrency | 0 | | innodb_flush_log_at_trx_commit | 1 | | slave_preserve_commit_order | OFF | +-----------------------------------------+-------+ 8 rows in set, 1 warning (0.00 sec)
E:/mysql-5.7.16-winx64/bin>net stop mysql MySQL 服务正在停止. MySQL 服务已成功停止。
E:/mysql-5.7.16-winx64/bin>net start mysql MySQL 服务正在启动 . MySQL 服务已经启动成功。
E:/mysql-5.7.16-winx64/bin>mysql -u root -proot mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 2 Server version: 5.7.16 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.
mysql> show global variables like '%commit%'; +-----------------------------------------+-------+ | Variable_name | Value | +-----------------------------------------+-------+ | autocommit | OFF | | binlog_group_commit_sync_delay | 0 | | binlog_group_commit_sync_no_delay_count | 0 | | binlog_order_commits | ON | | innodb_api_bk_commit_interval | 5 | | innodb_commit_concurrency | 0 | | innodb_flush_log_at_trx_commit | 1 | | slave_preserve_commit_order | OFF | +-----------------------------------------+-------+ 8 rows in set, 1 warning (0.01 sec)