65

Having spent a number of years working primarily with MS SQL Server (and hence SQL Server Management Studio for common tasks), I am now beginning to work with MySql. To date I have been using MySQL Workbench and am generally happy with it.

I would, however, like to be able to assign custom keyboard shortcuts for certain commands (e.g. commands from this list). For example, I'd prefer to stick to the MS-SQL approach of 'F5' to execute queries, rather than hitting 'Modifier+Return'. I haven't yet come across a simple way to do this. My questions are then:

  • Is this possible somehow in MySQL Workbench (e.g. additional plugin)?
  • If not, do any of the alternatives to MySQL Workbench offer this functionality?

Environment:

  • Ubuntu 12.04 LTS, 32 bit
  • MySQL server version 5.5.24-0ubuntu0.12.04.1
  • MySQL Workbench Version 5.2.38, rev 8753

Cheers!

1
  • 7
    I wish I could upvote your question multiple times. I have returned here probably 10 times, because each time I upgrade my version of mysql-workbench, it wipes out my keybindings! Sep 17, 2014 at 17:48

1 Answer 1

81

You can modify the main_menu.xml file (for me on Ubuntu 12.04 this was in /usr/share/mysql-workbench/data/). After you modify it, you'll need to restart MySQL Workbench.

It'll look like this

    <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="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">Modifier+E</value>
    </value>

The second to last line (Modifier+E) was edited by me. Previously it said "Modifier+Shift+Return". Note that this is NOT an alias (you cannot have both).

5
  • 19
    Or if you want to make the keyboard match MS SQL Server, try this: <value type="string" key="shortcut">F5</value> Dec 12, 2013 at 14:22
  • 14
    C:\Program Files\MySQL\MySQL Workbench x.x\data\ for Windows users May 14, 2015 at 0:07
  • 5
    Thanks Tyler. I located file in macOS (mac os x) as well. It sits here: /Applications/MySQLWorkbench.app/Contents/Resources/data/main_menu.xml. Enjoy!
    – Mateusz
    Nov 23, 2016 at 9:14
  • For windows x64 this file available under C:\Program Files\MySQL\MySQL Workbench 8.0\data\main_menu.xml Jul 9, 2022 at 8:23
  • 1
    Note, when you upgrade workbench it overwrites your main_menu.xml, so save a backup of your customizations!
    – Matthew
    Oct 28, 2022 at 18:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.