How to use MySQL exit and quit and \q commands with examples

In this post I’m going to quickly explain how to use MySQL exit and quit and \q commands to return to the operating system’s command line shell.

When working with MySQL at the command line you’ll arrive at a point when you are finished working.  Thus, you’ll want to exit mysql and return back to your operating system’s command shell.  MySQL provides two keywords for doing this, namely, exit and quit as well as a shorthand version \q.

So for example, say you’re sitting at the mysql command line and it looks like this…

mysql>

And you wish to go back to your command shell…

mysql>exit

-OR-

mysql>quit

(Type either exit or quit and press enter)

You can also use some shorthand to exit or quit the command line.  You can use the \q to quit as well.

It looks like this…

mysql>\q

(Type \q and press enter)

It’s as simple as that.  Learning how to use the MySQL command line can be powerful and efficient.  These three commands will help you on your way to using the command line more effectively.