MySQL Workbench: Adding F5 to execute

I’ve been using Microsoft’s SQL Server Management Studio since it was called Enterprise Manager, way back when.
Over the years, I have become so accustomed to using F5 to run queries that when even after a long time using MySQL Workbench, muscle memory rules and I still hit F5 and wonder why my queries don’t run…

Luckily, MySQL Workbench is configurable so the keyboard shortcuts can be changed.

To make MySQL Workbench behave more like SSMS, open an administrative command prompt (editing the configuration file requires administrator access) and CD to the directory MySQL Workbench has been installed in.
In there, you’ll find a directory called “data”, so CD into that. For version 8.0 installed on 64-bit Windows, I have this as cd "\Program Files\MySQL\MySQL Workbench 8.0 CE\data"

You’ll need to edit the file called main_menu.xml. I’ll just use notepad for this: notepad main_menu.xml

There are quite a few entries in this file for executing queries, but the one which makes it behave most like SSMS is the one which has an id of com.mysql.wb.menu.query.exec. The caption in version 8.0 is Execute (All or Selection). Change the shortcut to F5, as shown below:

<value type=”object” struct-name=”app.MenuItem” id=”com.mysql.wb.menu.query.exec”>
<link type=”object” key=”owner” struct-name=”app.MenuItem”>com.mysql.wb.menu.query</link>
<value type=”string” key=”accessibilityName”>Execute All or Selection</value>
<value type=”string” key=”caption”>Execute (All or Selection)</value>
<value type=”string” key=”name”>query.execute</value>
<value type=”string” key=”command”>builtin:query.execute</value>
<value type=”string” key=”itemType”>action</value>
<value type=”string” key=”shortcut”>F5</value>
</value>

When done, save and close the file and then restart MySQL Workbench. The Query menu will show F5 as the shortcut for the Execute All or Selection menu.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.