Reputation: 2717
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?
Upvotes: 149
Views: 222083
Reputation: 5340
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';
Upvotes: 17
Reputation: 21
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.
Upvotes: 2
Reputation: 4358
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
Upvotes: 9
Reputation: 1191
You just need to click on console at the bottom of the screen in phpMyAdmin and you will get the Executed history:
Upvotes: 76
Reputation: 27858
Yes, you can log queries to a special phpMyAdmin DB table.
See SQL_history.
Upvotes: 8
Reputation: 4151
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:
Upvotes: 7
Reputation: 1
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!
Upvotes: 0
Reputation: 1450
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.
Upvotes: 0
Reputation: 2717
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.
Upvotes: 117
Reputation: 47
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.
Upvotes: 3
Reputation: 1214
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
Upvotes: 97
Reputation: 1
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/
Upvotes: -5
Reputation: 1014
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.
Upvotes: 3
Reputation: 212412
I may be wrong, but I believe I've seen a list of previous SQL queries in the session file for phpmyadmin sessions
Upvotes: 2