Windows – How to exit MySQL command prompt

command lineexitMySQLwindows

I have installed MySQL. Now I am stuck inside the MySQL command prompt. I ran MySQL like this:

C:\>mysql.exe
mysql>

Then I type in some invalid command like this:

mysql> /version
    ->

And no matter what I type, I can't exit MySQL command-line / terminal. E.g.:

  • exit

  • CtrlC

  • CtrlD

  • quit

  • Ctrl\

  • CtrlZ

  • bye

How do I exit the MySQL terminal to the default terminal?

Best Answer

To add on to the other answer, you could simply end the current invalid query using a semicolon:

mysql> /version
    -> ;
ERROR 1064 (42000): You have an error in your SQL syntax.........
mysql> exit
Bye

c:\mysql\bin>

Or using \G (which is supposed to make rows display vertically):

mysql> /version
    -> ;
ERROR 1064 (42000): You have an error in your SQL syntax.........
mysql> exit
Bye

c:\mysql\bin>

Of course, both options assume you have no opening quote. If you do, you must first close it off with an ending quote.

Related Question