欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 运维知识 > 数据库 >内容正文

数据库

mysql禁用历史命令_如何禁止mysql记录历史命令

发布时间:2025/3/8 数据库 48 豆豆
生活随笔 收集整理的这篇文章主要介绍了 mysql禁用历史命令_如何禁止mysql记录历史命令 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

如何禁止mysql记录历史命令?在执行 SQL命令时,mysql会将历史命令记录到~/.mysql_history文件中,因此我们用上下键就可以翻阅历史命令了。

也许某些特殊需要我们可能需要不让它记录这些历史命令,我们可以这样作:

[root@TestServer root]# ln -s /dev/null $HOME/.mysql_history

这个方法来自官方手册,下面是摘录:

On Unix, the mysql client writes a record of executed statements to a history file. By default, the history file is named .mysql_history and is created in your home directory. To specify a different file, set the value of the MYSQL_HISTFILE environment variable.

If you do not want to maintain a history file, first remove .mysql_history if it exists, and then use either of the following techniques:

Set the MYSQL_HISTFILE variable to /dev/null. To cause this setting to take effect each time you log in, put the setting in one of your shell’s startup files.

Create .mysql_history as a symbolic link to /dev/null:

shell> ln -s /dev/null $HOME/.mysql_history

You need do this only once.

总结

以上是生活随笔为你收集整理的mysql禁用历史命令_如何禁止mysql记录历史命令的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。