Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

There is something in the MySQL console that drives me nuts. When I hit ctrl+c to cancel the current command being typed, the terminal exits.

In every terminal I know (*nix terminals, Python, PostgreSQL), ctrl+c cancels the current command and ctrl+d exits the terminal.

This issue has been reported at 2003, and bumped several times since.

Is there a way to:

  • Change this behaviour, or
  • Convince the MySQL dev team that this is really annoying?
share|improve this question

3 Answers 3

up vote 3 down vote accepted

To change the behaviour, download the source for the mysql CLI and modify the SIGINT handler to behave as you see fit, then recompile & install.

share|improve this answer

While the ctrl+c behavior is annoying, you can still use \c to cancel the current query. You just have to train yourself that when using mysql CLI, you use \c instead of ctrl+c!

share|improve this answer

What version of the client are you using? I remember this being the older behavior but recent versions of 5.1 and 5.5 seem to just cancel the running command without exiting the client. Then again it may be that I'm using the Percona builds. You could try just running their client if that's the case.

share|improve this answer
    
hmm, I'm running 5.5 Percona and ctrl+c still aborts the mysql client (not the current sql command) –  Derek Downey Jul 9 '12 at 15:19
    
I think I misread the OP. My response was addressing a command that was in the middle of being executed, not the desire to blank you a yet to be run command. –  atxdba Jul 9 '12 at 15:23
    
I concur with @atxdba - I'm also running the Percona build of 5.5, and ctrl+c drops out of the currently executing command. If there is no command executing, it drops out of the CLI. It may be that ctrl+d drops out of a shell that is running, but if you have a script running within the shell, that will stop if you hit ctrl+c... different commands for different apps / shells / scripts! Can be confusing... :~s –  Dave Rix Jul 9 '12 at 15:38
    
@DaveRix I agree too, ctrl+c drops out of a query that's currently executing. But that's not what the OP was about unfortunately. –  Derek Downey Jul 10 '12 at 13:55

Your Answer

 
discard

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.