MySQL Study之--MySQL关闭自动commit(autocommit) 对于mysql来讲,在事务处理时,默认是在动提交的(autocommit),以下方法可以自动关闭autocommit; 案例分析: 1、在mysql登录环境下修改 [root@mysql2 soft]# mysql -u root -p Enter password: Welcome
MySQL Study之--MySQL关闭自动commit(autocommit)
对于mysql来讲,在事务处理时,默认是在动提交的(autocommit),以下方法可以自动关闭autocommit;
案例分析:
1、在mysql登录环境下修改
[root@mysql2 soft]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.25-73.1 Percona Server (GPL), Release 73.1, Revision 07b797f
Copyright (c) 2009-2015 Percona LLC and/or its affiliates
Copyright (c) 2000, 2015, 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 databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.02 sec)
mysql> select version();
+-------------+
| version() |
+-------------+
| 5.6.25-73.1 |
+-------------+
1 row in set (0.00 sec)
mysql> show variables like '%autocommit%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| autocommit | ON | ;;默认autocommit是开启的
+---------------+-------+
1 row in set (0.03 sec)
在当前session关闭autocommit:
mysql> set @@session.autocommit=0;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like '%autocommit%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| autocommit | OFF |
+---------------+-------+
1 row in set (0.00 sec)
在global级别关闭autocommit:
mysql> set @@global.autocommit=0;
Query OK, 0 rows affected (0.01 sec)
创建普通用户:
mysql> create user tom identified by 'tom';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all on prod.* to 'tom'@'localhost' identified by 'tom';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
普通用户登录:
[root@mysql2 ~]# mysql -u tom -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.6.25-73.1 Percona Server (GPL), Release 73.1, Revision 07b797f
Copyright (c) 2009-2015 Percona LLC and/or its affiliates
Copyright (c) 2000, 2015, 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> use mysql;
ERROR 1044 (42000): Access denied for user 'tom'@'localhost' to database 'mysql'
mysql> use prod;
Database changed
mysql> show tables;
Empty set (0.00 sec)
mysql> show variables like '%commit%';
+-------------------------------------------+-------+
| Variable_name | Value |
+-------------------------------------------+-------+
| autocommit | OFF |
| binlog_order_commits | ON |
| innodb_api_bk_commit_interval | 5 |
| innodb_commit_concurrency | 0 |
| innodb_flush_log_at_trx_commit | 1 |
| innodb_use_global_flush_log_at_trx_commit | ON |
+-------------------------------------------+-------+
6 rows in set (0.00 sec)
创建测试表:
mysql> create table t1(id int,name varchar(10));
Query OK, 0 rows affected (0.15 sec)
mysql> insert into t1 values (10,'tom');
Query OK, 1 row affected (0.00 sec)
mysql> select * from t1;
+------+------+
| id | name |
+------+------+
| 10 | tom
|
+------+------+
1 row in set (0.00 sec)
事务回滚:
mysql> rollback;
Query OK, 0 rows affected (0.02 sec)
mysql> select * from t1;
Empty set (0.00 sec)
2、在mysql service重启后
mysql server 重启后:
[root@mysql2 ~]# service mysql stop
Shutting down MySQL (Percona Server)....[ OK ]
[root@mysql2 ~]# service mysql start
Starting MySQL (Percona Server).....[ OK ]
[root@mysql2 ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.25-73.1 Percona Server (GPL), Release 73.1, Revision 07b797f
Copyright (c) 2009-2015 Percona LLC and/or its affiliates
Copyright (c) 2000, 2015, 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 variables like '%commit%';
+-------------------------------------------+-------+
| Variable_name | Value |
+-------------------------------------------+-------+
| autocommit | ON | ;;autocommit仍然是开启状态
+-------------------------------------------+-------+
6 rows in set (0.01 sec)
编辑/etc/my.cnf文件:
[root@mysql2 ~]# vi /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
init_connect='set autocommit=0' ;;用户登录时,关闭autocommit
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
explicit_defaults_for_timestamp=true
innodb_buffer_pool_size = 128M
join_buffer_size = 128M
sort_buffer_size = 2M
read_rnd_buffer_size = 2M
用户登录查看:
[root@mysql2 ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.25-73.1 Percona Server (GPL), Release 73.1, Revision 07b797f
Copyright (c) 2009-2015 Percona LLC and/or its affiliates
Copyright (c) 2000, 2015, 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 variables like '%commit%';
+-------------------------------------------+-------+
| Variable_name | Value |
+-------------------------------------------+-------+
| autocommit | ON | ;;root用户不受影响(为安全起见)
mysql> system mysql -u tom -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.25-73.1 Percona Server (GPL), Release 73.1, Revision 07b797f
Copyright (c) 2009-2015 Percona LLC and/or its affiliates
Copyright (c) 2000, 2015, 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 variables like '%commit%';
+-------------------------------------------+-------+
| Variable_name | Value |
+-------------------------------------------+-------+
| autocommit | OFF | ;;普通用户,autocommit已被关闭
+-------------------------------------------+-------+

在当今快节奏的数字世界中,能够自动执行计算机任务可以极大地提高生产力和便利性。其中一项任务是关闭计算机,如果手动完成,这可能会非常耗时。值得庆幸的是,Python为我们提供了一套强大的工具来与系统交互并自动执行此类任务。在这篇博文中,我们将探讨如何编写Python脚本来轻松关闭计算机。无论您是想安排自动关机、远程启动关机,还是只是通过避免手动关机来节省时间,此脚本都会派上用场。导入所需的模块在开始编写脚本之前,我们需要导入必要的模块,以便与系统交互并执行关闭命令。在本节中,我们将导入os模块(它

win10电脑如何关闭语音识别功能?相信有很多时候用户使用电脑时都会通过语音识别来快速的完成其他操作。不过也有部分用户在使用电脑的过程中不想要使用这个功能,那么我们要如何去关闭这个语音识别功能呢?下面就和小编一起来看看Win10关闭语音识别的攻略吧。Win10关闭语音识别的攻略1、在开始菜单单击鼠标右键,选择控制面板2、将控制面板【查看方式】修改为大图标,在下面点击语音识别3、点击左侧的高级语音选项4、将下面启动时运行语音识别前面的勾去掉,点击确定即可。

win11快速启动有必要关闭吗?win11的快速启动可以帮助用户快速完成电脑开机,十分方便。但是也有不少用户认为正常启动比起快速启动,更能让电脑硬件进行充分休息。那么win11的快速启动和正常启动模式到底有什么区别呢?快速启动功能有必要进行关闭吗?今天小编就来给大家详细说明一下吧。win11快速启动和正常启动区别介绍快速启动就是你的电脑没有实现根本意义上的关机。电脑在关机或者休眠后,计算机的内存是无法存储文件的,所以电脑会将内存中的所有内容保存到硬盘中,生成一个指定的文件,而在唤醒休眠或者再次开

多任务处理通常需要您同时打开同一应用程序的多个窗口。虽然打开这些窗户似乎并不难,但管理它们可能会很痛苦。如果您正在寻找一种除了使用专用键盘快捷键之外一次关闭所有窗口应用程序的简单方法,本文将对您有很大帮助。如何在Windows11中一次关闭所有程序?1.使用任务栏在任务栏上查找打开多个活动程序的程序。右键单击其任务栏图标,然后选择“关闭所有窗口”选项。这可能是最简单,最快的方法,但是如果打开多个窗口的后台进程太多,则必须多次重复此过程,直到清除任务栏。或者,您可以使用旧的紧急键盘快捷键+.预览面

Win11怎样关闭445端口?445号端口是一个TCP端口,是一个共享文件夹和打印机端口,在局域网内提供文件或打印机共享服务。近期有部分Win11用户想要关闭445端口,那么应该如何操作呢?很多小伙伴不知道怎么详细操作,小编下面整理了Win11关闭445端口的详细操作,如果你感兴趣的话,跟着小编一起往下看看吧! Win11关闭445端口的详细操作 1、首先,按Win+S组合键,或点击底部任务栏上的搜索图标,打开的Windows搜索窗口,顶部输入Windows防火墙,然后点击系统给出的最佳

有的用户在使用外接鼠标操作win7电脑的时候,左手老是不小心碰到触摸板导致操作失误,那么在win7系统笔记本如何关闭触摸板呢?下面一起来看看吧。1、打开电脑端底部的主菜单栏,选择如图的【控制面板】。2、进入到面板栏中,点击如图的【硬件和声音】选项。3、然后继续选择打开如图的【鼠标】选项。4、在上方菜单中,找到【触控板】选项,将其打开。5、在这里就可以调节设置触控板的设置属性了。6、将其取消选择,然后点击下方的应用确定,这样就可以关闭触控板了。以上笔记本win7系统关闭触摸板的操作大家学会了没有呢

win7交互式服务检测怎么关闭?各位在使用电脑的过程中,是否有遇到过交互式服务检测这一提示窗口呢?该窗口一般都是由于病毒入侵导致的系统自动防护所引起的,因此我们需要对其十分重视,各位在关闭其之前,最好对电脑进行一次全面杀毒,那么,我们究竟要怎么关闭交互式服务检测这一窗口呢?下面就由小编为大家带来win7交互式服务检测关闭方法。win7交互式服务检测关闭方法1、首先按下左下角的“开始”按钮,然后在弹出的菜单窗口里点击“控制面板”选项。2、把“管理工具”打开后,接下来再点击“服务”。3、接着找到名为

尽管说3D加快可以让视觉冲击有一定的提高,但3D加快作用十分占有运行内存,许多朋友要想关掉这一作用却不知怎么实际操作,那麼碰到这样的情况该怎么办呢?下边就和小编一起来看一看是如何解决的吧。Win7关掉3D加快的方式1、按住“win+r”键盘快捷键,开启运行窗口键入“dxdiag”按回车键开启DirectX确诊专用工具。2、随后将页面转换到“表明”查询,就可以查询到系统软件是不是打开3d加快。3、随后退回到桌面,再度按“win+r”键盘快捷键,开启运行窗口键入“regedit”按回车键开启注册表编


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

螳螂BT
Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。

SecLists
SecLists是最终安全测试人员的伙伴。它是一个包含各种类型列表的集合,这些列表在安全评估过程中经常使用,都在一个地方。SecLists通过方便地提供安全测试人员可能需要的所有列表,帮助提高安全测试的效率和生产力。列表类型包括用户名、密码、URL、模糊测试有效载荷、敏感数据模式、Web shell等等。测试人员只需将此存储库拉到新的测试机上,他就可以访问到所需的每种类型的列表。

PhpStorm Mac 版本
最新(2018.2.1 )专业的PHP集成开发工具

Dreamweaver CS6
视觉化网页开发工具

禅工作室 13.0.1
功能强大的PHP集成开发环境