mongodb - 如何更改 .dbshell 历史文件位置
问题描述
在Win10中使用cmd,终止mongo服务后,出现错误:
保存历史文件时出错:FileOpenFailed Unable to fopen() file C:\Users\鍒桦简鏂叽叽.dbshell:访问被拒绝。
如果将Powershell 与 Admin 一起使用,我将在以下位置获得这个奇怪的文件C:\Users
:
鍒樺簡鏂嘰.dbshell
那么,错误是由于我的非英文名称目录的原因而发生的,那么如何更改.dbshell
文件在MongoDB中的位置?谢谢!
解决方案
您可以使用环境变量设置它USERPROFILE
:
c:\>set USERPROFILE=C:\Temp Files\IMP
c:\>mongo --norc
MongoDB shell version v4.4.1
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("b242c05d-68d5-48a5-ba06-43665f3eb2e9") }
MongoDB server version: 4.4.1
MongoDB Enterprise > db
test
MongoDB Enterprise > print("Hello World")
Hello World
MongoDB Enterprise > exit
bye
c:\>cat "C:\Temp Files\IMP\.dbshell"
db
print("Hello World")
c:\>
请参阅如何访问 Mongo shell 历史文件或 Windows 上的所有历史记录
请注意,在启动时 mongo shell 会读取 file %USERPROFILE%\.mongorc.js
,因此您可能还必须移动此文件。
推荐阅读
- javascript - 添加 svg 并使用 javascript 元素
- visual-studio - 从 VS 连接到 Azure Devops 2019 上的 NuGet 源
- python - Keras:多个输出和自定义损失函数的干净实现?
- reactjs - react项目中如何使用jspdf CDN
- angular - Angular parameter seems to have no effect in Style
- javascript - javascript 正则表达式应以有效匹配结尾
- pyvmomi - 使用 VMware SDK 触发主机自定义 shell 命令
- c# - 外部表在 c# 中不是预期的格式 - 部署后
- gradle - 如何遍历目录树,找到jar文件并将它们复制到gradle构建脚本中构建阶段之后的单个目录
- less - 更少的 CSS 映射问题