Recovering auto-saved files in MySQL Workbench

MySQL workbench is an open source tool for designing databases. As version 6.0.8, it is one of those programs where you need to save often, because the window you are working in will vanish every couple of hours.

Bug #1: Can’t recover files that weren’t saved

I was unlucky enough to have forgotten to save my work when it crashed today, and found this nasty flaw in the auto-recover feature:

Auto-save model interval: An open model that has not been saved will automatically be saved after this period. On loading a model file, MySQL Workbench will notify the user if the file was not previously saved correctly, due to a crash or power failure. MySQL Workbench can then attempt to recover the last auto-saved version. For automatic recovery to be available for a new file, it will have to have been saved at least once by the user.

Uh oh! The file hadn’t been saved yet, so it’s gone right? According to wb_model_file.cpp, this is not the case. The auto-save file is always written, but the recovery process wont be started until you try to use it again (which will never happen if you don’t have an old saved version):

/* Auto-saving
 * Auto-saving works by saving the model document file (the XML) to the expanded document folder
 * from time to time, named as document-autosave.mwb.xml. The expanded document folder is
 * automatically deleted when it is closed normally.
 * When a document is opened, it will check if there already is a document folder for that file
 * and if so, the recovery function will kick in, using the autosave XML file.

So under ~/.mysql/workbench/, I found a newmodel.mwbd folder. Workbench files are .zip files in disguise, so I compared it to a test file. It had all the same content, but with a document-autosave.xml, rather than a document.xml (see test file below):

Test archive

Cool, so I’d just rename the file, compress the whole lot and make it a .mwb? No such luck.

Bug #2: File Roller can’t compress ‘@’ files

Possibly because of the -@ command-line option in the zip command, File Roller refused to work with these files.

File Roller bug

Luckily, the document.mwb.xml file alone is enough for the file to be recognised and recovered from the auto-saved files:

File is recovered

The take-away from this? Save your work. In 2014, you still can’t count on auto-save to do this!

9 Replies to “Recovering auto-saved files in MySQL Workbench”

  1. If you are using Workbench 6.3, go to

    You will find all the scripts you have written (saved and unsaved) in date-wise saved files. You can open these files with an editor and decode the HTML entities. Its a long shot but you dont lose your work.

  2. Following on Iqal Baig said – The actual workspaces can be seen in C:\Users\[username]\AppData\Roaming\MySQL\Workbench\sql_workspaces

    If you look in the .SCRATCH files it’s all of your tabs. Only know this because I changed my connection name and all of my work files went away. Thanks for pointing me in the right direction

  3. Hello! This happened to me and I was wondering my system did not prompt me to recover the file?… I see it on my computer and when I open it a text editor like visual studio all the code is in there… How do I get it back into workbench? Sorry if this is obvious. I just started using SQL this week.

  4. @Ashley- It’s a flaw in the auto-save feature. At least in version 6.0.8, you could rename the autosave file ‘document.xml’, put the XML in a zip file, and MySQL workbench would still open it.

Leave a Reply

Your email address will not be published. Required fields are marked *