How to deal with the .mysql.history file in mysql
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.