Is there a way to view past mysql queries with phpmyadmin?

MysqlPhpmyadmin

Mysql Problem Overview


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?

Mysql Solutions


Solution 1 - Mysql

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

Solution 2 - Mysql

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

Solution 3 - Mysql

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

Solution 4 - Mysql

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

SELECT * FROM `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';

Solution 5 - 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

Solution 6 - Mysql

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

See SQL_history.

Solution 7 - Mysql

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

Solution 8 - Mysql

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.

Solution 9 - Mysql

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.

Solution 10 - Mysql

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

Solution 11 - Mysql

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.

Solution 12 - Mysql

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.

Solution 13 - Mysql

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!

Solution 14 - Mysql

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/

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionchris1979View Question on Stackoverflow
Solution 1 - Mysqlchris1979View Answer on Stackoverflow
Solution 2 - MysqlalleyoopsterView Answer on Stackoverflow
Solution 3 - MysqlSamarth SaxenaView Answer on Stackoverflow
Solution 4 - MysqlSyed Waqas BukharyView Answer on Stackoverflow
Solution 5 - MysqlbaolView Answer on Stackoverflow
Solution 6 - MysqlblueyedView Answer on Stackoverflow
Solution 7 - MysqlDhinakarView Answer on Stackoverflow
Solution 8 - MysqlAnurag PrashantView Answer on Stackoverflow
Solution 9 - MysqlJackhererView Answer on Stackoverflow
Solution 10 - MysqlMark BakerView Answer on Stackoverflow
Solution 11 - MysqlSmallOutside.comView Answer on Stackoverflow
Solution 12 - MysqlOmid AhmadyaniView Answer on Stackoverflow
Solution 13 - MysqlDisplay NameView Answer on Stackoverflow
Solution 14 - MysqlNishant KumarView Answer on Stackoverflow