MySql workbench query history ( last executed query / queries ) i.e. create / alter table, select, insert update queries

MysqlMysql WorkbenchHistory

Mysql Problem Overview


Want to see last executed queries in MySql Workbench whether its

> create / alter table query > > select / insert / update query or any query list.

in short want to see history of all queries

Mysql Solutions


Solution 1 - Mysql

From the bottom panel, change "Action Output" to "History" and then choose the appropriate date.

Alternatively, the SQL statement history is stored in text files under two locations:

  • sql_history/yyyy-mm-dd e.g., sql_history/2015-04-01: Full Workbench SQL history for all MySQL connections
  • log/sql_actions_.log*: SQL history execution results, but without the data, and separated per MySQL connection

The location of these files depends on your system. For additional details, see MySQL Workbench Settings and Log Files

In both cases, you will see the query history.

enter image description here

Solution 2 - Mysql

C:\Users[WinUser]\AppData\Roaming\MySQL\Workbench\sql_history

you find a log file for each day. It includes manual and automated queries from workbench (e.g. UPDATES via edit in Table)

Solution 3 - Mysql

Suppose that you can no longer connect to a previous MySQL database instance, and you just want to see your SQL history from the editors. Do this:

  1. Locate your MySQLWorkbench settings folder:
  • Windows: %AppData%\MySQL\Workbench\ -- which is usually C:\Users\your_username\AppData\MySQL\Workbench\ (Note that the AppData folder is hidden by default, so you may want to unhide AppData first, to see its contents.)
  • macOS: /Users/your_username/Library/Application Support/MySQL/Workbench/ (Note that the ~/Library folder is hidden by default, so you may want to unhide it first, to see the contents)
  • Linux: /Users/your_username/.mysql/workbench/
  1. Open the folder sql_workspaces (inside Workbench)

  2. You should see folders of your previous database connections. Navigate into one of them.

  3. There should be several "*.scratch" files. They are text files of editor history of SQL queries.

  4. Open these *.scratch files in a text editor, and copy the contents.

Solution 4 - Mysql

You will find a complete History file in:

C:\Users\[WinUser]\AppData\Roaming\MySQL\Workbench\log\sql_actions_unconnected.txt

MySQL Workbench could not open History file for some reason, but I was able to recover my unsaved queries by browsing this history file.

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
Questionmurtaza.webdevView Question on Stackoverflow
Solution 1 - MysqlPhilip OlsonView Answer on Stackoverflow
Solution 2 - MysqlAlexView Answer on Stackoverflow
Solution 3 - MysqlMr-IDEView Answer on Stackoverflow
Solution 4 - MysqlMiguel LoyaView Answer on Stackoverflow