How to quit and exit from MySQL/MariDB SQL prompt without saving

I am using mysql command with mariadb server. I typed sql query at the mysql>

select * from foo;

Is it possible to quit this query i.e. do not run and return to mysql prompt? Is it possible to exit to the shell prompt directly and not run SQL command?

You can press backspace to delete the SQL query.

Another option is to type Type ‘\c’ to clear the current input SQL statement.

mysql> select * from foo [ENTER]
\c [ENTER]
mysql>

Above statement won’t be running. Finally you can always press the [CTRL]+c to abort current session. It is recommend that you always keep the backups. Good luck!


Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki