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

社会主义新天地 提交于 2019-11-30 04:41:35

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.

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)

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\
    • macOS: /Users/~username/Library/Application Support/MySQL/Workbench/
    • Linux: /Users/~username/.mysql/workbench/
  2. Open the folder sql_workspaces

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

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

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!