How to clear MySQL console screen

Learn how to clear MySQL console screen for Windows, macOS, and Linux

Posted on November 05, 2021


When you’re inside the mysql command line client, trying to clear the console using the clear command won’t work.

This is because clear is a system shell command that’s unrecognized by mysql client:

mysql> clear
# nothing happens...

To clear the console, you need to add the \! symbol before the clear command.

The \! symbol can be used in mysql client to execute a system shell command. The syntax is as shown below:

\! shell-command

When you’re in a Unix-like OS like Linux or macOS, you can clear the mysql console screen with the following command:

mysql> \! clear
# clears the mysql console screen

Alternatively, you can also use the CTRL + L command to clear the screen.

If you’re accessing MySQL from the Command Prompt in Windows OS, then you need to replace the clear command with the cls command.

Here’s an example of clearing the screen for Windows Command Prompt. Click the image to open it in a new tab:

And that’s how you can clear the MySQL console screen in Windows, Linux, and macOS.

Related articles:

Level up your programming skills

I'm sending out an occasional email with the latest programming tutorials. Drop your email in the box below and I'll send new stuff straight into your inbox!

No spam. Unsubscribe anytime.