获取/记录以前运行的SQL查询列表

发布于 2025-01-24 08:42:22 字数 306 浏览 5 评论 0 原文

来自这个问题,我知道我可以使用<代码<代码>显示完整的ProcessList 以获取活动查询列表。但是查询在运行查询后消失。是否有一种方法可以在查询运行时列出先前运行的查询或某些日志文件?

注意 - 我正在使用dbeaver使用显示完整的ProcessList 查看查询。

From this question, I learned that I can use SHOW FULL PROCESSLIST to get a list of active queries. But the query disappears after running the query. Is there a way to list the previously run queries or to some log files when a query is running?

Note - I'm using DBeaver to view queries using SHOW FULL PROCESSLIST

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一页 2025-01-31 08:42:22

查询经理在这种情况下为您提供帮助。转到“窗口/显示视图/查询管理器”,或从主工具栏中的交易选项旁边的下拉菜单中选择它。

The query manager helps you in this case. Go to "Window/ Show View/ Query Manager" or select it from the drop-down menu beside transaction options in the main toolbar.

enter image description here

雅心素梦 2025-01-31 08:42:22

我发现这适用于Mariadb实例,因此它可能适用于您使用的MySQL。

有一个记录功能可以设置并启用DB记录所有查询的所有查询。这是我发现的链接,然后在下面复制的是步骤。

首先在DBEAVER中连接到DB。然后运行以下语句以启用记录。

SET GLOBAL general_log_file ='/var/log/mysql/mycustom.log';
SET GLOBAL log_output = 'FILE';
SET GLOBAL general_log = 'ON';
SHOW VARIABLES LIKE "general_log%";

您最终将获得一个文件 mycustom.log var/log/mysql/下,每个查询都针对DB进行了。

改编自:

I found this works for a MariaDB instance so it might work for whatever MySQL you're using.

There is a logging feature that can be setup and enabled for the DB to log out all queries executed. Here is a link I found and then copied below are the steps.

First connect to your DB in DBeaver. Then run the following statements to enable logging.

SET GLOBAL general_log_file ='/var/log/mysql/mycustom.log';
SET GLOBAL log_output = 'FILE';
SET GLOBAL general_log = 'ON';
SHOW VARIABLES LIKE "general_log%";

What you will end up with is a file mycustom.log under var/log/mysql/ with every query that was ran against the DB.

Adapted from: https://gist.github.com/joseluisq/40ec9169669aa1848492141fa6f57fcb

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文