有没有办法用 phpmyadmin 查看过去的 mysql 查询?
我正在尝试查找删除 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(14)
好吧,我实际上偶然发现了答案。
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.
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
您只需在phpMyAdmin中单击屏幕底部的控制台即可获得执行历史记录:
You just need to click on console at the bottom of the screen in phpMyAdmin and you will get the Executed history:
要查看过去的查询,只需在 phpMyAdmin 中运行此查询即可。
如果未启用,请在运行之前运行以下两个查询。
To view the past queries simply run this query in phpMyAdmin.
if it is not enabled, run the following two queries before running it.
我认为 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
是的,您可以将查询记录到特殊的 phpMyAdmin DB 表中。
请参阅SQL_history。
Yes, you can log queries to a special phpMyAdmin DB table.
See SQL_history.
我正在使用 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:您必须单击 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.
好吧,我知道我有点晚了,上面的一些答案很棒。
不过,在任何 PHPMyAdmin 页面中,请执行以下操作:
这将显示您最后输入的查询。
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:
this will then show your last entered query.
我可能是错的,但我相信我已经在 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
这是一些可能有用的技巧:
对于选择查询(仅),您可以创建视图,特别是当您发现自己一遍又一遍地运行相同的选择查询时,例如在生产支持场景中。
创建视图的主要优点是:
您只需单击结果表显示底部的“创建视图”链接即可轻松创建视图。
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:
You can create a view easily by simply clicking the "Create view" link at the bottom of the results table display.
你可以使用 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.
为什么不使用导出,然后单击“自定义 - 显示所有可能的选项”单选按钮,然后选择您的数据库,然后转到“输出”并选择“以文本形式查看输出”,只需向下滚动即可继续。瞧!
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!
有一个名为 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/