Get the App
SLTechnology News&Howtos  ›  Database  › 

How to deal with the .mysql.history file in mysql

Shulou Source: shulou.com Published: 2022-05-31 21:02:16 10月03日 Update

The purpose of this article is to share with you how to deal with the .mysql.history file in mysql. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article.

After installing mysql, there will be a .MySQL _ history file in the root home directory

[root@potato ~] # ll-a | grep .MySQL _ history

-rw-. 1 root root 1472 Dec 9 00:07 .mysql _ history

Root@potato ~] # tail-20. MySQL _ history

Show\ 040global\ 040variables\ 040like\ 040 percent% percent'

Show\ 040global\ 040variables\ 040like\ 040% long%'

.

Look, it contains all the statements we've executed before.

Ps: there is a problem of\ 040 escape character error at this time. It should be a space.

Why is this file generated? its purpose is to achieve the ability to flip up and down in the mysql command.

Every time the mysql connection exits, the information of this operation will be recorded in the ~ / .mysql_history file.

However, all our operations are in it. What if someone sees this file with trespassing?

So the existence of this file poses a threat to our database, so how to deal with it?

In fact, it is also very simple.

Use .MySQL _ history as a soft connection to / dev/null, which is equivalent to outputting all statements to / dev/null

[root@potato] # ln-f-s / dev/null ~ / .mysql_history

[root@potato ~] # cat. MySQL _ history

.MySQL _ history becomes an empty file

This is how to deal with the .mysql.history file in mysql. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Tags: Files more knowledge articles sentences practical up and down information commands characters that is work sessions data databases articles directories purposes see knowledge points spaces Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft NVidia Shulou Tech Info Shulou Technology vpn