Lurtz
Lurtz

Reputation: 83

Restore unsaved MySQL Workbench scripts?

I had a bunch of unsaved scripts open. Today I restarted MySQL Workbench, there was an error message and now the scripts are gone. Is there a way to restore them somehow?

Upvotes: 8

Views: 22979

Answers (4)

yagni
yagni

Reputation: 1210

This just happened to me and thankfully it turns out MySQL Workbench does actually autosave tab contents to disk. You can find them starting at your base configuration file path which is described here. The path to the scratch files is something like this:

{BASE_CONFIG_PATH}/sql_workspaces/{CONNECTION_NAME}.autosave/

Inside that folder is a bunch of .scratch files, looks like one per tab you had open for that connection. They're named with UUIDs, but just drop them all in a text editor and you should be able to find your lost tab contents pretty quickly.

Upvotes: 4

nunnithan
nunnithan

Reputation: 51

If the save snapshot option is enable (this can be done by --> Edit>Preferences>SQL Editor>Save snapshot of open editors on close) then you can find the data in \%APPDATA%\MySQL\Workbench\log\sql_actions_unconnected.log. It is a log file, you can copy your code and paste it in a code editor which would put the code in the right format

Upvotes: 4

avenir-arcadius
avenir-arcadius

Reputation: 76

You can try to find your script in History Output. Check this answer: MySql workbench query history ( last executed query / queries ) i.e. create / alter table, select, insert update queries

Upvotes: 5

Miguel Guerreiro
Miguel Guerreiro

Reputation: 356

If they're gone, they're gone, unfortunately. You should save them before you exit WorkBench (CTRL+S), since it has been very prone to errors like that, at least to me.

Upvotes: 0

Related Questions