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.