我尝试使用以下 mysql 历史记录文件:
tail -f ~/.mysql_history
Run Code Online (Sandbox Code Playgroud)
在我作为同一用户输入的另一个窗口中:
mysql -u someotheruser -p
Run Code Online (Sandbox Code Playgroud)
并且我的尾巴中没有显示以下命令。当我退出 mysql 控制台时, 中仍然没有显示任何内容tail -f
,但是,当cat
我查看历史文件时,我看到文件末尾有新条目
那是因为mysql
完全重新创建.mysql_history
在运行期间文件。
因此,当您cat ~/.mysql_history
在mysql
执行后运行时,您会看到完全不同的文件。不是那个tail
在读书。
您可以通过一个简单的测试轻松检查它:
$ ls -li .mysql_history
6685441 -rw------- 1 user user 1570 Sep 15 21:26 .mysql_history
$ mysql i_test
...
mysql> Bye
$ ls -li .mysql_history
6685474 -rw------- 1 user user 1592 Nov 29 20:27 .mysql_history
Run Code Online (Sandbox Code Playgroud)
如您所见,inode 有所不同。所以这就是答案。