Leo
Leo

Reputation: 263

Gracefully cancel a MySQL statement in console while typing it

In MySQL's console, how do I gracefully cancel a MySQL statement while in the middle of typing it?

For example, let's say I type SELECT and then hit the ENTER key. My console now looks like this:

mysql> SELECT
    ->

Now, if I change my mind and no longer want to complete the SELECT statement, how do I cancel it?

If I type Ctrl-C, then this completely exits the MySQL console, which is not what I want.

I can also type a semicolon and prematurely run the statement, but this results in a SQL syntax error. I would prefer not to pollute MySQL's query log if possible.

Upvotes: 0

Views: 171

Answers (1)

akuzminsky
akuzminsky

Reputation: 2257

End the statement with \c:

mysql> select
    -> \c
mysql>

Upvotes: 1

Related Questions