有没有办法用 phpmyadmin 查看过去的 mysql 查询?

发布于 2024-09-09 02:40:18 字数 197 浏览 4 评论 0原文

我正在尝试查找删除 mysql 表中行的错误。

在我的一生中,我无法在我的 PHP 代码中找到它,所以我想通过找到删除行的实际 mysql 查询来逆向工作。

我登录了phpmyadmin,但找不到查看过去sql操作历史记录的方法。

有没有办法在 phpmyadmin 中查看它们?

I'm trying to track down a bug that's deleting rows in a mysql table.

For the life of me I can't track it down in my PHP code, so I'd like to work backwards by finding the actual mysql query that's removing the rows.

I logged in to phpmyadmin, but can't find a way to view the history of past sql operations.

Is there a way to view them in phpmyadmin?

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

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

发布评论

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

评论(14

-残月青衣踏尘吟 2024-09-16 02:40:18

好吧,我实际上偶然发现了答案。

phpMyAdmin 确实提供了一个简短的历史。如果您单击“phpMyAdmin”徽标下方的“sql”图标,它将打开一个新窗口。在新窗口中,只需单击“历史记录”选项卡。

这将为您提供最后二十个左右的 SQL 操作。

输入图片描述这里

Ok, so I actually stumbled across the answer.

phpMyAdmin does offer a brief history. If you click on the 'sql' icon just underneath the 'phpMyAdmin' logo, it'll open a new window. In the new window, just click on the 'history' tab.

That will give you the last twenty or so SQL operations.

enter image description here

牵你手 2024-09-16 02:40:18

SQL(查询)屏幕底部有一个控制台选项卡。默认情况下,它不会展开,但一旦单击它,就会显示“选项”、“历史记录”和“清除”选项卡。单击历史记录。

查询历史记录长度是在页面相关设置中设置的,通过单击屏幕右上角的齿轮即可找到该设置。

这对于 PHP 版本 4.5.1-1 是正确的

There is a Console tab at the bottom of the SQL (query) screen. By default it is not expanded, but once clicked on it should expose tabs for Options, History and Clear. Click on history.

The Query history length is set from within Page Related Settings which found by clicking on the gear wheel at the top right of screen.

This is correct for PHP version 4.5.1-1

过期以后 2024-09-16 02:40:18

您只需在phpMyAdmin中单击屏幕底部的控制台即可获得执行历史记录:

在此处输入图像描述

You just need to click on console at the bottom of the screen in phpMyAdmin and you will get the Executed history:

enter image description here

数理化全能战士 2024-09-16 02:40:18

要查看过去的查询,只需在 phpMyAdmin 中运行此查询即可。

SELECT * FROM `mysql`.`general_log`

如果未启用,请在运行之前运行以下两个查询。

SET GLOBAL log_output = 'TABLE';
SET GLOBAL general_log = 'ON';

To view the past queries simply run this query in phpMyAdmin.

SELECT * FROM `mysql`.`general_log`

if it is not enabled, run the following two queries before running it.

SET GLOBAL log_output = 'TABLE';
SET GLOBAL general_log = 'ON';
为人所爱 2024-09-16 02:40:18

我认为 phpMyAdmin 不允许您这样做,但我想听听我错了。

另一方面,您可以在 MySQL 中启用查询日志记录:一般查询日志

I don't think phpMyAdmin lets you do that, but I'd like to hear I'm wrong.

On the other hand you can enable query logging in MySQL: The General Query Log

暖心男生 2024-09-16 02:40:18

是的,您可以将查询记录到特殊的 phpMyAdmin DB 表中。

请参阅SQL_history

Yes, you can log queries to a special phpMyAdmin DB table.

See SQL_history.

明月松间行 2024-09-16 02:40:18

我正在使用 phpMyAdmin 服务器版本:5.1.41。

它提供了通过phpmyadmin.pma_history表查看sql历史记录的可能性。

您可以在此表中搜索您的查询。

pma_history 表具有以下结构:

在此处输入图像描述

I am using phpMyAdmin Server version: 5.1.41.

It offers possibility for view sql history through phpmyadmin.pma_history table.

You can search your query in this table.

pma_history table has below structure:

enter image description here

初见 2024-09-16 02:40:18

您必须单击 phpMyAdmin 徽标下方的查询窗口,将打开一个新窗口。
只需单击“SQL 历史记录”选项卡即可。在那里您可以看到 SQL 查询的历史记录。

You have to click on query window just below the phpMyAdmin logo, a new window will open.
Just click on SQL History tab. There you can see history of SQL Queries.

只有影子陪我不离不弃 2024-09-16 02:40:18

好吧,我知道我有点晚了,上面的一些答案很棒。

不过,在任何 PHPMyAdmin 页面中,请执行以下操作:

  1. 单击 SQL 选项卡
  2. 单击“获取自动保存的查询”,

这将显示您最后输入的查询。

OK so I know I'm a little late and some of the above answers are great stuff.

As little extra though, while in any PHPMyAdmin page:

  1. Click SQL tab
  2. Click 'Get auto saved query'

this will then show your last entered query.

倾城月光淡如水﹏ 2024-09-16 02:40:18

我可能是错的,但我相信我已经在 phpmyadmin 会话的会话文件中看到了以前的 SQL 查询列表

I may be wrong, but I believe I've seen a list of previous SQL queries in the session file for phpmyadmin sessions

暖伴 2024-09-16 02:40:18

这是一些可能有用的技巧:

对于选择查询(仅),您可以创建视图,特别是当您发现自己一遍又一遍地运行相同的选择查询时,例如在生产支持场景中。

创建视图的主要优点是:

  • 它们驻留在数据库中,因此是永久的
  • 它们可以在会话和用户之间共享 它们
  • 提供了使用表的所有常见好处
  • 它们可以进一步查询,就像表一样,例如过滤结果此外,
  • 由于它们在底层作为查询存储,因此不会增加任何开销。

您只需单击结果表显示底部的“创建视图”链接即可轻松创建视图。

Here is a trick that some may find useful:

For Select queries (only), you can create Views, especially where you find yourself running the same select queries over and over e.g. in production support scenarios.

The main advantages of creating Views are:

  • they are resident within the database and therefore permanent
  • they can be shared across sessions and users
  • they provide all the usual benefits of working with tables
  • they can be queried further, just like tables e.g. to filter down the results further
  • as they are stored as queries under the hood, they do not add any overheads.

You can create a view easily by simply clicking the "Create view" link at the bottom of the results table display.

丘比特射中我 2024-09-16 02:40:18

你可以使用 run /PATH_PAST_MYSQL/bin/mysqld.exe 运行你过去的 mysql,

它运行你最后的 mysql,你可以在 phpmyadmin 和系统的其他部分看到它。

注意:停止当前的 mysql 版本。

SF我的英语。

you can run your past mysql with run /PATH_PAST_MYSQL/bin/mysqld.exe

it run your last mysql and you can see it in phpmyadmin and other section of your system.

notice: stop your current mysql version.

S F My English.

热鲨 2024-09-16 02:40:18

为什么不使用导出,然后单击“自定义 - 显示所有可能的选项”单选按钮,然后选择您的数据库,然后转到“输出”并选择“以文本形式查看输出”,只需向下滚动即可继续。瞧!

why dont you use export, then click 'Custom - display all possible options' radio button, then choose your database, then go to Output and choose 'View output as text' just scroll down and Go. Voila!

没︽人懂的悲伤 2024-09-16 02:40:18

有一个名为 Adminer 的工具,它能够完成打包在单个小型 php 文件中的所有 phpmyadmin 工作。
http://www.techinfobit.com/如何在没有任何额外安装的情况下导入导出数据库/

There is a tool called Adminer which is capable of doing all phpmyadmin job packed in single tiny php file.
http://www.techinfobit.com/how-to-import-export-database-without-any-extra-installation/

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