phpMyAdmin Query History Exporter
Free to download on every platform. Comes pre-installed on BotFone, BotPad and BotFlip — with extra free apps included.
About this app
WHAT IT DOES
This userscript adds a query history exporter to your phpMyAdmin interface. It reads SQL query history entries from the page—extracting the SQL query text, timestamp, execution status, table name, database, and duration—and displays them in a clean panel with a summary of total queries, successful queries, errors, and most frequent tables. The preview section shows your most recent queries. An export button formats all queries as either a SQL script (with optional comments) or a CSV file for easy import into spreadsheets or analysis tools. This is invaluable for database administrators, developers, and analysts who need to audit database activity, document query patterns, recover lost queries, or analyze query performance.
WHERE IT RUNS
The script runs on all phpMyAdmin web application pages at any path containing "/phpmyadmin/" or "/phpMyAdmin/". It works across all phpMyAdmin interfaces by using multiple selector strategies to find query history entries, SQL text, timestamps, and execution status. The script detects dynamic content loading and re-renders the panel when the query history updates. It runs across the entire phpMyAdmin domain, ensuring coverage whether you're viewing the query history page, the SQL console, or the query viewer.
HOW TO USE
Install the script via the BotGentz extension and navigate to any phpMyAdmin page with query history. The query history panel will appear automatically, showing a summary of your query history. The panel displays total queries, successful queries, errors, and the most frequent tables. A preview section shows your five most recent queries. Use the panel controls to customize your experience: toggle the panel on or off, enable or disable auto-export on page load, choose between SQL script or CSV export format, or include or exclude comments in SQL exports. Click the "Export All Queries" button to copy all queries to your clipboard in your chosen format. The "Copy Preview" button exports only the previewed queries, and the "Refresh" button manually rescans the page for updated history.
THE MECHANISM - QUERY EXTRACTION, TABLE FREQUENCY ANALYSIS, AND EXPORT FORMATTING
This script identifies query history entries by scanning the DOM for known phpMyAdmin elements. It uses a cascading selector strategy that looks for query history entries (.query-history-entry, .history-query, .sql-history-item), then extracts SQL text from code or query elements, timestamps from date elements, status from status indicators, and table names by parsing SQL queries with regular expressions. The script identifies table names by matching FROM, INTO, UPDATE, JOIN, TABLE, and ON clauses. Table frequency analysis counts occurrences of each table across all queries. For export, SQL scripts include each query as a statement with optional comments (timestamp, status, table). CSV exports include columns for timestamp, table, status, duration, and SQL text. The export is copied to the clipboard using GM_setClipboard. Auto-export, when enabled, automatically copies the full export on page load with a desktop notification.
THE PANEL
The control panel appears as a floating, draggable element that you can position anywhere on the phpMyAdmin page. Drag by the header to reposition it, and the position is saved per site using GM_setValue so it stays where you left it across sessions. Release the panel near any edge and it snaps into place, keeping your workspace organized. Click the panel header to collapse it into a small bubble showing only the document emoji (📝), minimizing distraction while keeping controls accessible. Drag from the bubble to restore the full panel. The panel automatically resizes to fit its content and includes the summary metrics, table frequency list, query preview, export settings, and action buttons. Press the Escape key to quickly collapse the panel to its minimized state. The panel remains visible across page navigation within phpMyAdmin, with query history updating automatically as you move between pages.
PLEASE NOTE
This script requires the free BotGentz extension to function. It is designed for phpMyAdmin users who need to export and analyze query history. The script reads only visible query history data from the DOM—it does not access the MySQL database directly, your credentials, or any sensitive information. All settings (panel visibility, auto-export, export format, comment inclusion, and panel position) are stored locally using GM_setValue and never leave your browser. The script does not modify your phpMyAdmin data—it only reads and exports visible query history. The query extraction relies on the query history being visible on the page; if the history is not loaded or the page structure changes, the script may show limited information. If phpMyAdmin updates its website structure, the script may need to be updated to match new selectors. The auto-export feature copies queries to your clipboard automatically; you can disable it if you prefer manual control.