Reputation: 443
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?
Upvotes: 7
Views: 19215
Reputation: 55
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.
Upvotes: 0
Reputation: 21
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:\>
Upvotes: 1
Reputation: 51
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.
Upvotes: 0
Reputation: 99
I prefer to do it using '\c' to clear wrong commands which is also suggested by mysql itself.
In your case you should
Upvotes: 3
Reputation: 137
'> indicates that you added an extra single quote in your query. To end the statement, close the open single quote by typing ';
Upvotes: 2
Reputation: 134
I got this done with ' then ; then press ENTER, without that semicolon it doesn't work in my case.
Upvotes: 0
Reputation: 630
You may give ';
on the prompt to come out of that without exiting MySQL.
If this does not work, try a '
and then ';
Upvotes: 4
Reputation: 7880
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.
Upvotes: 16
Reputation: 193
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?
Upvotes: 3
Reputation: 61
Just end the command with a semicolon ";". MySQL will display an error message and let you continue.
Upvotes: 0