Clearing the Screen in MySQL
The main purpose of this topic is to demonstrate how to clear the MySQL console screen.
Clearing the Screen in MySQL
When working on the MySQL Console and managing configuration and data, the screen can become overly cluttered with the results of previous actions. Clutter can result in a cluttered display, which can affect visualization of future queries, because a cluttered display can cause confusion when navigating through the output.
Consider the following scenario:
C:\Users\Admin>mysql --user=root --password=root
MySQL: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.30 MySQL Community Server - GPL
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> SELECT * from world.city;
+------+---------------+-------------+----------------------+------------+
| ID | Name | CountryCode | District | Population |
+------+---------------+-------------+----------------------+------------+
| 1 | Kabul | AFG | Kabol | 1780000 |
| 2 | Qandahar | AFG | Qandahar | 237500 |
| 3 | Herat | AFG | Herat | 186800 |
| 4 | Mazar-e-Sharif| AFG | Balkh | 127800 |
| 5 | Amsterdam | NLD | Noord-Holland | 731200 |
| . | . . . . . . . | . . . . . . | . . . . . . . . . . | . . . . . |
| . | . . . . . . . | . . . < OUTPUT REDACTED > . . . | . . . . . |
| . | . . . . . . . | . . . . . . | . . . . . . . . . . | . . . . . |
| 4078 | Nablus | PSE | Nablus | 100231 |
| 4079 | Rafah | PSE | Rafah | 92020 |
+------+---------------+-------------+----------------------+------------+
4079 rows in set (0.07 sec)
mysql>
After executing such a large query, it becomes annoying to go back and check something, especially when looking for a specific result in the middle of the output. It is difficult to find it among all the output.
To overcome this, we can clear the screen while we are in progress to prevent the screen from getting cluttered.
We can clear MySQL console in many ways, some of them are as follows:
Clear the MySQL console using the system
Depending on the operating system, the system following cmdlets for clearing the screen can be used to clear the MySQL console.
Here are examples for Linux, Mac, and Windows:
Clear MySQL Console in Linux
You can easily clear the screen on Linux using clear or reset.
# Only scrolls down
mysql> system clear
# For clearing both the history and scrollback history
mysql> system reset
With system clear, the shell will just scroll down, leaving the old results intact. If we need to remove the scroll, use system reset.
Clearing the MySQL Console in Windows
Likewise, for Windows:
mysql> system cls
We can also use its shortcuts \!
instead of writing systems.
### Linux
mysql> \! clear
mysql> \! reset
### Windows
mysql> \! cls
Clearing the MySQL console in macOS
On macOS, you can do the following:
Go to Edit, click Clear Screen or use the keyboard shortcut ⌥+Cmd+L
.
Clear the MySQL console in iTerm2
These settings are a bit renamed in iTerm. Use Clear Buffer instead of Clear Screen.
More specifically, go to Edit, click Clear Buffer, or use the keyboard shortcut Cmd+K .
For reprinting, please send an email to 1244347461@qq.com for approval. After obtaining the author's consent, kindly include the source as a link.
Related Articles
Get the version in MySQL
Publish Date:2025/04/24 Views:169 Category:MySQL
-
In this article, we will learn how to get the current version of MySQL on Windows systems. It is necessary for businesses to maintain versions of different tools and software used to run their business in order to keep systems compatible. T
Full Join in MySQL
Publish Date:2025/04/24 Views:70 Category:MySQL
-
This article aims to explore how to perform a full join or full outer join in MySQL. Full outer join is used to merge or combine the entire data from two separate tables. For example, suppose we have two tables named student_id and student_
Grouping by month in MySQL
Publish Date:2025/04/24 Views:166 Category:MySQL
-
In this article, we will learn how to group values by month in MySQL database. Businesses and organizations have to find user or customer data based on purchase or usage trends over a few months. If a particular business achieves its
Enabling the slow query log in MySQL
Publish Date:2025/04/24 Views:177 Category:MySQL
-
Today, we will enable MySQL in MySQL using MySQL shell on Windows and Ubuntu 20.04 slow_query_log . For this tutorial, we are using MySQL version 8.0 and Ubuntu 20.04. MySQL slow_query_log MySQL slow_query_log contains SQL statements that t
Update multiple tables in MySQL with one query
Publish Date:2025/04/24 Views:65 Category:MySQL
-
In some cases, users want to update logically related tables at the same time. These logically related tables are linked to each other through some attributes. Advantages of updating multiple tables in one MySQL query Similar attributes in
Checking MySQL version in macOS
Publish Date:2025/04/24 Views:60 Category:MySQL
-
In this article, we aim to explore how to check the current version of MySQL on macOS. Checking MySQL version in macOS When trying to figure out the version, you must follow these steps. Each time a person logs into the MySQL server, the ve
Common table expressions in MySQL
Publish Date:2025/04/24 Views:168 Category:MySQL
-
This article aims to understand how to use common table expressions in MySQL. Most data analysts need to store the results of different queries in order to merge them with a separate query. With the help of common tables, expressions can ma
Sorting by date in MySQL
Publish Date:2025/04/24 Views:156 Category:MySQL
-
This article aims to understand how to sort values by date in MySQL. Most of the businesses and organizations that use MySQL for data analysis or data visualization need to sort different table values of their users based on dat
Sort MySQL data alphabetically
Publish Date:2025/04/24 Views:153 Category:MySQL
-
In this article, we aim to explore how to sort data alphabetically in MySQL database. Sorting is the ordering of elements or values in an array or column based on a particular criteria. In this tutorial, we will set the criteria as al