Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In the MySQL/MariaDb command line client, if I have the cursor in the middle of a long query and I want to abandon that command I have to

  1. reposition cursor at the end of the line
  2. check whether the end of the line already has ; or \G or \g, and if so backspace to delete those.
  3. if the query (often loaded onto the current line by accessing history) contains several SQL commands, I would need to ensure that none of those was going to execute by replacing all ;s with \c
  4. append \c
  5. hit Enter.


  1. reposition cursor at start of line
  2. type # to make the whole thing a comment
  3. hit Enter.

This is a huge amount of work for a common need. In bash, I hit Ctrl-C and it gives me a fresh command prompt ignoring whatever else was on that line. But of course, do that in MySQL and it exits the whole client.

Is there a shortcut for this?

share|improve this question

A couple shorter options:

  • Ctrl-A to get to the beginning of the line, followed by Ctrl-K to (forward) kill the entire line.
  • Ctrl-E to get to the end of the line, followed by Ctrl-U to (backward) kill the entire line.
share|improve this answer
Can't use Ctrl-A because I'm always in tmux but the E, U, one looks a hopeful shortcut to learn, thank you. – artfulrobot Sep 26 '13 at 20:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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