Mysql查看sql是否走事务
登陆进入server
[root@gzmtest_25 ~]# su - mysql [mysql@gzmtest_25 ~]$ mysql.local Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 126000553 Server version: 5.5.27-log Sourcedistribution Copyright (c) 2000, 2011, Oracle and/or itsaffiliates. All rights reserved. Oracle is a registered trademark of OracleCorporation and/or its affiliates. Other names may be trademarksof their respective owners. Type 'help;' or '\h' for help. Type '\c' toclear the current input statement.
能够看到监控日志是否开启的选项(off是关闭)on是开启
root@localhost:(none)>show global variables like 'general_log%'; +------------------+---------------------------+ | Variable_name | Value | +------------------+---------------------------+ | general_log | OFF | | general_log_file |/data/mysql/log/mysql.log | +------------------+---------------------------+ 2 rows in set (0.01 sec) root@localhost:(none)> root@localhost:(none)>set global general_log=on; Query OK, 0 rows affected (0.02 sec)
查看当前系统日志大小
root@localhost:(none)>system du -h /data/mysql/log/mysql.log 1.7M /data/mysql/log/mysql.log
开启日志成功
接下来就能够直接进入shell中依据sql特征来查看我们sql会话信息
[root@gzmtest_25 ~]# grep "forupdate" /data/mysql/log/mysql.log 126002192 Query select pk fromT_GANTT_CHART where pk =47 for update <p>//忽略其它的数据了。 </p>
运行看当前会话的信息
[root@gzmtest_25~]# grep 126002192 /data/mysql/log/mysql.log 126002192Connect test@11.104.32.115 on test 126002192Query /* mysql-connector-java-5.1.6 (Revision: ${svn.Revision} ) */SHOW VARIABLES WHERE Variable_name ='language' ORVariable_name = 'net_write_timeout' OR Variable_name = 'interactive_timeout' ORVariable_name = 'wait_timeout' OR Variable_name = 'character_set_client' ORVariable_name = 'character_set_connection' OR Variable_name = 'character_set'OR Variable_name = 'character_set_server' OR Variable_name = 'tx_isolation' ORVariable_name = 'transaction_isolation' OR Variable_name ='character_set_results' OR Variable_name = 'timezone' OR Variable_name ='time_zone' OR Variable_name = 'system_time_zone' OR Variable_name ='lower_case_table_names' OR Variable_name = 'max_allowed_packet' ORVariable_name = 'net_buffer_length' OR Variable_name = 'sql_mode' ORVariable_name = 'query_cache_type' OR Variable_name = 'query_cache_size' ORVariable_name = 'init_connect' 126002192Query SHOW COLLATION 126002192Query SET character_set_results = NULL 126002192Query SET autocommit=1 126002192Query SETsql_mode='STRICT_TRANS_TABLES' 141017 11:20:49 126002192 Query SETautocommit=0 126002192Query commit 126002192Query SET autocommit=1 126002192Query select *....sql 太长忽略 126002192Query SELECTCOUNT(last_password_change) FROM T_PF_USER 126002192Query SELECT COUNT(password_salt) FROMT_PF_USER 126002192Query SELECT COUNT(comment_of_attendee)FROM T_PLUGIN_CALENDAR_EVENT_ATTENDEE 126002192Query SELECT COUNT(ext_subscription)FROM T_PLUGIN_CALENDAR 126002192Query SELECTCOUNT(ext_subscription_calendar_binary) FROM T_PLUGIN_CALENDAR 126002192Query SELECTCOUNT(ext_subscription_hash) FROM T_PLUGIN_CALENDAR 126002192Query SELECTCOUNT(ext_subscription_url) FROM T_PLUGIN_CALENDAR 126002192Query SELECTCOUNT(ext_subscription_update_interval) FROM T_PLUGIN_CALENDAR 126002192Query SELECT COUNT(*) FROMT_PLUGIN_TODO 126002192Query SELECT COUNT(*) FROMT_PLUGIN_MEMO //sql太长忽略 126002192Query SELECT @@session.tx_isolation 126002192Query SET SESSION TRANSACTION ISOLATIONLEVEL REPEATABLE READ 126002192Query SET autocommit=0 126002192Query select *....sql 太长忽略 126002192Query select *....sql 太长忽略 126002192Query select *....sql 太长忽略 126002192Query select *....sql 太长忽略 126002192Query select *....sql 太长忽略 126002192Query select pk from T_GANTT_CHARTwhere pk =47 for update 126002192Query select *....sql 太长忽略 126002192Query select *....sql 太长忽略 126002192Query select *....sql 太长忽略 126002192Query select *....sql 太长忽略 126002192Query select *....sql 太长忽略 126002192Query select *....sql 太长忽略 126002192Query select *....sql 太长忽略 126002192Query select *....sql 太长忽略 126002192Query select *....sql 太长忽略 126002192Query select *....sql 太长忽略 126002192Query select *....sql 太长忽略 126002192Query update T_GANTT_OBJECT setcreated='2014-08-19 16:56:49', deleted=0, last_update='2014-08-23 14:20:42',duration=0, endDate='2014-08-13 00:00:00', oId=-1, orderValue=20, parentId=237,preId=-1, predecessorOffset=0, progress=100, refId=-1, relationType='start_start',startDate='2014-08-05 00:00:00', id=96, title='01_系统设计',type='activity', visible=1 where pk=238 126002192Query update T_GANTT_CHART setcreated='2014-08-19 16:56:49', deleted=0, last_update='2014-10-17 11:22:18',gantt_objects_as_xml=237, name='3D项目', owner_fk=8,read_access='ALL', settings_as_xml='<ganttChartSettings><title>3D项目</title><openNodes/></ganttChartSettings>',style_as_xml='<ganttChartStyle xTicks="AUTO"width="1000"/>', task_fk=94, write_access='ALL' where pk=47 126002192Query update T_GANTT_OBJECT setcreated='2014-08-19 17:57:01', deleted=0, last_update='2014-08-23 14:20:42',duration=0, endDate='2014-10-18 00:00:00', oId=3, orderValue=20, parentId=241,preId=219, predecessorOffset=0, progress=null, refId=2, relationType='start_start',startDate='2014-10-15 00:00:00', id=100, title='促销数据',type='activity', visible=1 where pk=243 126002192Query commit 126002192Query SET autocommit=1 126002192Query SET SESSION TRANSACTION ISOLATIONLEVEL READ COMMITTED
依据上面的日志明显能够断定了:
当设置SET autocommit=1 之后的sql都是没有走事务的,
当SET autocommit=0之后到commit之前的都是走了事务的。
记要完成。
分析完成后别忘记把日志关闭,不然非常影响性能的哦
root@localhost:(none)>set global general_log=off; Query OK, 0 rows affected (0.00 sec) root@localhost:(none)>show global variables like 'general_log%'; +------------------+---------------------------+ | Variable_name | Value | +------------------+---------------------------+ | general_log | OFF | | general_log_file |/data/mysql/log/mysql.log | +------------------+---------------------------+ 2 rows in set (0.00 sec) root@localhost:(none)>
Mysql查看sql是否走事务的更多相关文章
- MySQL查看SQL语句执行效率
Explain命令在解决数据库性能上是第一推荐使用命令,大部分的性能问题可以通过此命令来简单的解决,Explain可以用来查看 SQL 语句的执行效 果,可以帮助选择更好的索引和优化查询语句,写出更好 ...
- MySQL查看SQL语句执行效率(转)
Explain命令在解决数据库性能上是第一推荐使用命令,大部分的性能问题可以通过此命令来简单的解决,Explain可以用来查看 SQL 语句的执行效 果,可以帮助选择更好的索引和优化查询语句,写出更好 ...
- MySQL查看当前运行的事务和执行的账户
-- 查看当前运行的事务,这点在变更表结构之前必须要查看select * from information_schema.innodb_trx; -- 查看当前运行的事务的账户和事务开始的时间,及其事 ...
- mysql查看sql语句的设置
SHOW VARIABLES LIKE "general_log%"; SET GLOBAL general_log_file = 'D:\\mysql.log'; SET GLO ...
- mysql查看sql执行情况的几种方法
mysql系统变量分为全局变量和会话变量,全局变量的修改影响到整个服务器,会话变量修改只影响当前的会话. 查看log日志是否开启 show variables like 'general_log' s ...
- mysql查看sql语句执行时间
原文地址: http://www.cnblogs.com/happySmily/p/5943311.html
- 两种方式:mysql查看正在执行的sql语句
mysql查看正在执行的sql语句 2015年08月21日 17:32:59 阅读数:15398 有2个方法: 1.使用processlist,但是有个弊端,就是只能查看正在执行的sql语句,对应 ...
- (2.9)Mysql之SQL基础——索引的查看与删除
(2.9)Mysql之SQL基础——索引的查看与删除 关键词:mysql索引查看,mysql索引删除 1.索引查询(以下包括主键,唯一,普通,复合,全文,但不包括外键) (1)按库查询 select ...
- (2.7)Mysql之SQL基础——表的操作与查看
(2.7)Mysql之SQL基础——表的操作与查看 搜索关键字:mysql表操作,comment注释操作,mysql临时表 0.临时表 create temporary table 1.创建表(在in ...
随机推荐
- 327 Count of Range Sum 区间和计数
Given an integer array nums, return the number of range sums that lie in [lower, upper] inclusive.Ra ...
- [转]Window2008站点安全设置,IIS7/IIS7.5中目录执行权限的设置方法
本文转自:http://blog.snsgou.com/post-510.html 最近帮一个朋友管理Window 2008服务器,发现有个站点是用asp写的,更可怕的是还有传说中的“上传漏洞”,在上 ...
- [ HAOI 2010 ] 最长公共子序列
\(\\\) \(Description\) 求两个长度\(\le5000\)的大写字母串的\(LCS\)长度及个数,定义两\(LCS\)中某一字符在两序列出现位置有一处不同就视为不同. \(\\\) ...
- css文本背景样式
文本样式 文本类 text-transform:uppercase: 全部变为大写 text-transform:lowercase: 全部变为小写 text-transform:capitalize ...
- 慕课网中网页定位导航中js相关问题总结
<!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title> ...
- ElasticSearch-5.21安装
环境 操作系统:Centos 6.5 X64 IP地址:192.168.56.100 JDK 环境: # java -version java version "1.8.0_121" ...
- 提高mysql千万级大数据SQL查询优化几条经验
凯哥java 微信号 kaigejava 功能介绍 ...
- html5——2D转换
transform 属性 1.向元素应用 2D 或 3D 转换 2.该属性允许我们对元素进行旋转.缩放.移动或倾斜. 缩放与位移 transform: scale(, 0.5);//水平缩放,垂直缩放 ...
- Caffe2:添加CUDA路径
在使用Eclipse时候,仍然出现 libcuda.so 找不到的情况..... 原因:cuda环境没有设置到系统环境中. 方案: 设置CUDA path: 在bashrc中添加路径,只对当前用户产生 ...
- Unity如何播放带有alpha 通道的视频
问题: 当使用Video Player播放带有alpha 通道的视频时带有黑色背景 解决方式: 使用文件格式为WEBM的视频,对视频文件进行的修改 在RawImage中,将New Render Tex ...