`

GLOBAL variable and should be set with SET GLOBAL

 
阅读更多
方法1,用命令开启慢查询

查看复制打印?
1.mysql> show variables like "%long%"; //查看一下默认为慢查询的时间10秒
2.+-----------------+-----------+
3.| Variable_name | Value |
4.+-----------------+-----------+
5.| long_query_time | 10.000000 |
6.+-----------------+-----------+
7.1 row in set (0.00 sec)
8.
9.mysql> set global long_query_time=2; //设置成2秒,加上global,下次进mysql已然生效
10.Query OK, 0 rows affected (0.00 sec)
11.
12.mysql> show variables like "%slow%"; //查看一下慢查询是不是已经开启
13.+---------------------+---------------------------------+
14.| Variable_name | Value |
15.+---------------------+---------------------------------+
16.| log_slow_queries | OFF |
17.| slow_launch_time | 2 |
18.| slow_query_log | OFF |
19.| slow_query_log_file | /usr/local/mysql/mysql-slow.log |
20.+---------------------+---------------------------------+
21.4 rows in set (0.00 sec)

22.set character_set_results=utf8;

23.mysql> set slow_query_log='ON'; //加上global,不然会报错的。
24.ERROR 1229 (HY000): Variable 'slow_query_log' is a GLOBAL variable and should be set with SET GLOBAL
25.mysql> set global slow_query_log='ON'; //启用慢查询
26.Query OK, 0 rows affected (0.28 sec)

27.
28.mysql> show variables like "%slow%"; //查看是否已经开启
29.+---------------------+---------------------------------+
30.| Variable_name | Value |
31.+---------------------+---------------------------------+
32.| log_slow_queries | ON |
33.| slow_launch_time | 2 |
34.| slow_query_log | ON |
35.| slow_query_log_file | /usr/local/mysql/mysql-slow.log |
36.+---------------------+---------------------------------+
37.4 rows in set (0.00 sec)
mysql> show variables like "%long%"; //查看一下默认为慢查询的时间10秒
+-----------------+-----------+
| Variable_name | Value |
+-----------------+-----------+
| long_query_time | 10.000000 |
+-----------------+-----------+
1 row in set (0.00 sec)

mysql> set global long_query_time=2; //设置成2秒,加上global,下次进mysql已然生效
Query OK, 0 rows affected (0.00 sec)

mysql> show variables like "%slow%"; //查看一下慢查询是不是已经开启
+---------------------+---------------------------------+
| Variable_name | Value |
+---------------------+---------------------------------+
| log_slow_queries | OFF |
| slow_launch_time | 2 |
| slow_query_log | OFF |
| slow_query_log_file | /usr/local/mysql/mysql-slow.log |
+---------------------+---------------------------------+
4 rows in set (0.00 sec)

mysql> set slow_query_log='ON'; //加上global,不然会报错的。
ERROR 1229 (HY000): Variable 'slow_query_log' is a GLOBAL variable and should be set with SET GLOBAL
mysql> set global slow_query_log='ON'; //启用慢查询
Query OK, 0 rows affected (0.28 sec)

mysql> show variables like "%slow%"; //查看是否已经开启
+---------------------+---------------------------------+
| Variable_name | Value |
+---------------------+---------------------------------+
| log_slow_queries | ON |
| slow_launch_time | 2 |
| slow_query_log | ON |
| slow_query_log_file | /usr/local/mysql/mysql-slow.log |
+---------------------+---------------------------------+
4 rows in set (0.00 sec)
分享到:
评论

相关推荐

    Google C++ Style Guide(Google C++编程规范)高清PDF

    Scoping Namespaces Nested Classes Nonmember, Static Member, and Global Functions Local Variables Static and Global Variables Classes Doing Work in Constructors Default Constructors Explicit ...

    微软内部资料-SQL性能优化3

    To make use of either more or less strict isolation levels in applications, locking can be customized for an entire session by setting the isolation level of the session with the SET TRANSACTION ...

    Artificial Neural Networks_New Research-Nova Science(2017).pdf

    Chemical content of scrap to be loaded and melted in the furnace was selected as the input variable while the specific electricity consumption was the output variable. Other studies modeled the ...

    BobBuilder_app

    In this version I have done away with the b+tree and hash index in favor of my own MGIndex structure which for all intents and purposes is superior and the performance numbers speak for themselves....

    grads-1.8sl11-linux

    Interactions and/or the Institute for Global Environment and Society be liable to you for damages, including any lost profits, lost monies, or other special, incidental or consequential damages ...

    Turbo C 2.00[DISK]

    system that uses an LCD or composite display, you should set your system to black and white mode before running INSTALL or TCINST. You can do this from DOS with the following command line: mode ...

    WPTools.v6.29.1.Pro

    set global variable WPDoNotAddExternalFontLeading := TRUE and select the Printer WYSIWYG mode: TWPRichText1.HeaderFooter.UpdateReformatMode(true) - The FormatOption wpDisableAutosizeTables can be ...

    FastReport.v4.15 for.Delphi.BCB.Full.Source企业版含ClientServer中文修正版支持D4-XE5

    + [enterprise] now any report file can be matched with any (one and more) group, these reports are accessible only in matched groups + [enterprise] now you can set-up cache delays for each report file...

    i-vector的工具箱

    A total variability subspace is learned from the development set and is used to estimate a low (and fixed) dimensional latent factor called the identity vector (i-vector) from adapted mean ...

    C# Game Programming Cookbook for Unity 3D - 2014

    4.4 Set Gravity.........................................................66 4.5 Pretend Friction—Friction Simulation to Prevent Slipping Around........66 4.5.1 Script Breakdown...........................

    ak2新版内核AKAIO1.5

    + New Super Mario Brothers Minigames on AK2: If they don't work, set Download Play to "Disabled" and boot in non-DMA mode (hold down A while loading) + Misc bug fixes (Too many to list). AK-AIO 1.2 +...

    Introduction_to_Optimum_Design.pdf

    4.1 Definitions of Global and Local Minima 84 4.1.1 Minimum 84 4.1.2 Existence of Minimum 89 4.2 Review of Some Basic Calculus Concepts 89 4.2.1 Gradient Vector 90 4.2.2 Hessian Matrix 92 4.2.3 Taylor...

    Dundas.Chart.for.Winform.Enterprise.v7.1.0.1812.for.VS2008

    Chart should not assume XValueIndex with all 0 datapoints. IndexWhenXIsZero added. When set to false and all points have an x-value of 0, the points will not index but all draw at 0 What’s new in ...

    php.ini-development

    > should be used and that this feature ; should be disabled, as enabling it may result in issues when generating XML ; documents, however this remains supported for backward compatibility reasons. ; ...

    FlexGraphics_V_1.79_D4-XE10.2_Downloadly.ir

    - FIX: Removed FG_NEWTEXTROTATE directive (the TFlexText Precise mode should be used instead). - FIX: The TFlexRegularPolygon object clones incorrectly drawed in case when TFlexRegularPolygon have ...

    Turbo C 2.01[DISK]

    system that uses an LCD or composite display, you should set your system to black and white mode before running INSTALL or TCINST. You can do this from DOS with the following command line: mode ...

    qemu-0.13.0(编译过全处理器支持)

    -g WxH[xDEPTH] Set the initial graphical resolution and depth -vnc display start a VNC server on display 1 target only: -win2k-hack use it when installing Windows 2000 to avoid a disk full bug -no-fd...

    acpi控制笔记本风扇转速

    ACPI_OPERAND_OBJECT has been manually optimized to be aligned and will not work if it is byte-packed. Example Code and Data Size: These are the sizes for the OS- independent acpica.lib produced by ...

    vim插件打包

    " 'g' global: find global definition(s) of the token under cursor " 'c' calls: find all calls to the function name under cursor " 't' text: find all instances of the text under cursor " 'e' egrep:...

    opensc-0.12.0.tar.gz

    * set version in configure.in, src/pkcs11/pkcs11-global.c, win32/version.rc and src/include/winconfig.h New in 0.9.4; 2004-10-31; Andreas Jellinghaus: * Library version was broken in 0.9.3. * Update...

Global site tag (gtag.js) - Google Analytics