Windows 控制台下 mysql 因缺少终止字符串的匹配符号,如何退出?

时间:2024-10-25 11:09:08

如下错误情况:
mysql> SELECT * FROM my_table WHERE name = 'Smith AND age < 30;
    '>

因为 mysql 引擎在等待单引号"'"结束,因此以下命令全部无效:
\q
quit;
exit;
ctrl+c

必须用如下方法,补上结束符的单引号“'”并执行清屏命令“\c”即可:
mysql> SELECT * FROM my_table WHERE name = 'Smith AND age < 30;
    '> '\c
mysql>

其它符号以此类推:

Prompt    Meaning
mysql>    Ready for new query
->    Waiting for next line of multiple-line query
'>    Waiting for next line, waiting for completion of a string that began with a single quote (')
">    Waiting for next line, waiting for completion of a string that began with a double quote (")
`>    Waiting for next line, waiting for completion of an identifier that began with a backtick (`)
/*>    Waiting for next line, waiting for completion of a comment that began with /*

更详细请查阅官方文档: https://dev.mysql.com/doc/refman/8.0/en/entering-queries.html