When you type a command into mySQL the wrong way, mySQL won’t run the command. Instead of giving an error it sometimes gives an endless list of:
'>
'>
'>
'>
each time you enter something, no matter what input you give it (besides using quit command). I’d like to stay logged in though, so quitting, logging back in and retrying the command with different syntax is very annoying.
Is there a shortcut to just quit a line if it bugs out and stay in the connection?
That prompt says you’re in the middle of a string, so just typing '
and then pressing enter will get you out.
Commented Jan 22, 2015 at 20:31
As per my comment above, the prompt '>
indicates that the MySQL shell is in the middle of a string and is waiting for you to close it.
Typing '
and pressing enter closes the string allowing the interpreter to carry on.
A similar prompt shows on various UNIX/Linux shells when a string hasn’t been terminated correctly.
You may give ';
on the prompt to come out of that without exiting MySQL.
If this does not work, try a '
and then ';
You should always terminate SQL commands with a semicolon. As soon as you realize you made a mistake, enter “;” to finish that command and mySQL will warn you that the command was incorrect.
Then you can write your query again. Is that what you were looking for?
Sometimes just adding a semicolon works, but not this time. For whatever reason it was apparently the string mark ‘ that wasn’t letting me kill the command, as Phylogenesis mentioned in comment under my question
– Kiwizoom
Commented Jan 22, 2015 at 20:37
I prefer to do it using ‘\c’ to clear wrong commands which is also suggested by mysql itself.
In your case you should
- Close the string with ” (or’)
- Use \c to clear the command.
![Can't quit incorrect mySQL command line 3 example](https://i.sstatic.net/ctF4n.png)
‘> indicates that you added an extra single quote in your query. To end the statement, close the open single quote by typing ‘;
mysql> hello
->
-> look dash is on the left"
"> In doublequote mode now, because doublequote above
"> adding another doublequote breaks you out: "
-> look a single quote ' here
'> in single quote mode now.
'> get out, in, then out again with three single quotes: '''
-> now it will listen to your escape code: \c
mysql> exit
Bye
C:\>
Just end the command with a semicolon “;”. MySQL will display an error message and let you continue.
I got this done with ‘ then ; then press ENTER, without that semicolon it doesn’t work in my case.
If semi-colon ‘;’ does not terminate a query, just type ‘\c’ and the command line will clear everything up, and be ready to take a new query.
As for the people suggesting to use semicolon (;) to get out, that’s fine, but I’d be cautious about just throwing the semicolon just anywhere. That semicolon will execute the query, even if the user had realized midway that he/she did not want to do so…
Example (table name is “species”):
mysql> drop table species
-> ;
Query OK, 0 rows affected (0.003 sec)
And just like that, the table is gone, of course. Just be careful.
source from https://stackoverflow.com/questions/28098061/cant-quit-incorrect-mysql-command-line