當我運行mongo客戶端時,它在$ HOME/.dbshell中存儲命令的歷史記錄。我寧願不記錄來自Mongo的任何命令。如何禁用mongo .dbshell歷史文件
如何禁用寫入.dbshell文件的行爲?我不想將它寫入/ tmp,我想避免將它寫入任何地方。
此頁面不提供有用的信息here。
當我運行mongo客戶端時,它在$ HOME/.dbshell中存儲命令的歷史記錄。我寧願不記錄來自Mongo的任何命令。如何禁用mongo .dbshell歷史文件
如何禁用寫入.dbshell文件的行爲?我不想將它寫入/ tmp,我想避免將它寫入任何地方。
此頁面不提供有用的信息here。
截至MongoDB的3.4,還有就是禁用mongo
殼歷史功能沒有明確的選項。
可能的解決方法是使歷史記錄文件爲只讀。如果.dbshell
文件無法讀取或寫入,則mongo
外殼將繼續保持無錯誤狀態。
例如,一個類Unix系統上:
# Ensure an empty history file
echo "" > ~/.dbshell
# Remove rwx access to the history file
chmod 0 ~/.dbshell
我提出在MongoDB的問題跟蹤器,您可以觀看,給予好評,或發表評論,此功能建議:SERVER-29103: Add option to disable writing shell history to .dbshell。
你可以控制這個文件的創建位置。
所以 看看here。
void shellHistoryInit() {
stringstream ss;
const char* h = shell_utils::getUserDir();
if (h)
ss << h << "/";
ss << ".dbshell";
historyFile = ss.str();
linenoiseHistoryLoad(historyFile.c_str());
linenoiseSetCompletionCallback(completionHook);
}
,所以如果你從這個函數的文件不應該被創建返回falsy值:
const char* getUserDir() {
#ifdef _WIN32
return getenv("USERPROFILE");//make sure this is empty
#else
return getenv("HOME");
#endif
}
對不起 - 我不想控制它將在哪裏創建,我想避免它被創建在第一個地方。 –
這是他們如何在mongo源內部實現它 –