Logan Logan - 1 year ago 123
MySQL Question

How do you clear an unexecuted MySQL query from the command line?

Suppose you're typing a command line query into a MySQL database and you need to cancel out and start over. From a bash shell you could just type ctrl-c and get a new prompt. In MySQL, ctrl-c would exit the client and return you to the shell.

For example, I have a long, complex SELECT statement typed in but I haven't yet hit return. I realize that I don't want to send the command but I want to have the command on-screen so I can use it as a reference. I'd like to bail out without quitting MySQL. Any ideas?

Key point: the command hasn't yet been executed.

Answer Source

Type \c.

When you start up MySQL, you'll likely see this message:

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

The "buffer" that it's referring to is the command/query buffer.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download