Last Updated: February 25, 2016
·
630
· Saager Mhatre

Cancel mistyped statement in MySQL client

Ever end up in a situation where you've written a fairly long statement into the MySQL client and then realized that it was wrong? So wrong that you wanted to start over?

Hitting enter might just report an error and drop you back at the mysql prompt, or it could end up executing something you don't want to.

If you haven't set mysql to ignore sig-int, then a ^C is going to drop you clean out of the client, which means having to log in again.

A quick way to get out of this sticky situation is to tag a \c onto the end of your (incorrect) statement. This will tell MySQL to cancel that buffer and restore the old one.