国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > MySQL > 正文

mysql查看sql語句執行歷史記錄的例子

2024-07-24 12:39:35
字體:
來源:轉載
供稿:網友

下面來為各位介紹一個mysql查看sql語句執行歷史記錄的例子,如果你希望跟蹤你程序的執行性能我們就可以使用下面方法,有需要了解的朋友可進入看看.

mysql查看sql語句執行歷史記錄:

cat ~/.mysql_history

對于mysql版本5.1以后的版本,可以通過以下方式啟動日志記錄,能夠記錄下包括應用程序執行的sql語句.

  1. MariaDB [(none)]> SET GLOBAL log_output = 'TABLE'
  2. Query OK, 0 rows affected (0.02 sec) 
  3. MariaDB [(none)]> SET GLOBAL general_log = 'ON'
  4. Query OK, 0 rows affected (0.00 sec) 
  5. MariaDB [(none)]> show databases; 
  6. +--------------------+ 
  7. Database | 
  8. +--------------------+ 
  9. | information_schema | 
  10. | gfan_log | 
  11. | gfan_pay | 
  12. | gfanpg | 
  13. | gfanrc | 
  14. | mysql | 
  15. | performance_schema | 
  16. | ucenter | 
  17. +--------------------+ 
  18. rows in set (0.02 sec) 
  19. MariaDB [(none)]> use mysql 
  20. Reading table information for completion of table and column names 
  21. You can turn off this feature to get a quicker startup with -A 
  22. Database changed 
  23. MariaDB [mysql]> show tables; 
  24. +---------------------------+ 
  25. | Tables_in_mysql | 
  26. +---------------------------+ 
  27. | columns_priv | 
  28. | db | 
  29. | event | 
  30. | func | 
  31. | general_log | 
  32. | help_category | 
  33. | help_keyword | 
  34. | help_relation | 
  35. | help_topic | 
  36. | host | 
  37. | ndb_binlog_index | 
  38. | plugin | 
  39. | proc | 
  40. | procs_priv | 
  41. | proxies_priv | 
  42. | servers | 
  43. | slow_log | 
  44. | tables_priv | 
  45. | time_zone | 
  46. | time_zone_leap_second | 
  47. | time_zone_name | 
  48. | time_zone_transition | 
  49. | time_zone_transition_type | 
  50. user | 
  51. +---------------------------+ 
  52. 24 rows in set (0.00 sec) 
  53. MariaDB [mysql]> select * from general_log limit 10; 
  54. +----------------------------+---------------------------+-----------+-----------+--------------+-------------------+ 
  55. | event_time | user_host | thread_id | server_id | command_type | argument | 
  56. +----------------------------+---------------------------+-----------+-----------+--------------+-------------------+ 
  57. | 2014-11-12 14:29:49.810999 | root[root] @ localhost [] | 1304 | 0 | Query | show databases | 
  58. | 2014-11-12 14:29:51.951747 | root[root] @ localhost [] | 1304 | 0 | Query | SELECT DATABASE() | 
  59. | 2014-11-12 14:29:51.973180 | root[root] @ localhost [] | 1304 | 0 | Init DB | mysql | 
  60. | 2014-11-12 14:29:51.975048 | root[root] @ localhost [] | 1304 | 0 | Query | show databases | 
  61. | 2014-11-12 14:29:51.975689 | root[root] @ localhost [] | 1304 | 0 | Query | show tables | 
  62. | 2014-11-12 14:29:51.976347 | root[root] @ localhost [] | 1304 | 0 | Field List | columns_priv |  --Vevb.com 
  63. | 2014-11-12 14:29:51.976800 | root[root] @ localhost [] | 1304 | 0 | Field List | db | 
  64. | 2014-11-12 14:29:51.977431 | root[root] @ localhost [] | 1304 | 0 | Field List | event | 
  65. | 2014-11-12 14:29:51.978052 | root[root] @ localhost [] | 1304 | 0 | Field List | func | 
  66. | 2014-11-12 14:29:51.978224 | root[root] @ localhost [] | 1304 | 0 | Field List | general_log | 
  67. +----------------------------+---------------------------+-----------+-----------+--------------+-------------------+ 
  68. 10 rows in set (0.01 sec) 
  69. MariaDB [mysql]> 
  70.  
  71. If you want to output to the log file: 
  72. SET GLOBAL log_output = “FILE”; 
  73. SET GLOBAL general_log_file = “/path/to/your/logfile.log” 
  74. SET GLOBAL general_log = ‘ON’; 
  75. Restart MySQL to apply the changes if you edit the config, e.g. /etc/mysql/my.cnf 
  76. Now, if you’d like you can tail -f /var/log/mysql/mysql.log

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 琼海市| 凤庆县| 湖州市| 宁远县| 香格里拉县| 黑龙江省| 慈利县| 治县。| 迭部县| 建德市| 马山县| 金阳县| 黑山县| 南安市| 长沙市| 杭锦旗| 灵台县| 淳安县| 余姚市| 安塞县| 巫溪县| 凤阳县| 普兰店市| 裕民县| 东阳市| 黄冈市| 临江市| 天全县| 通许县| 敦煌市| 灵台县| 伊春市| 灌南县| 湘潭市| 调兵山市| 布尔津县| 称多县| 拜泉县| 凤凰县| 平凉市| 体育|