运行“mongod”时出现“NonExistentPath: 未找到数据目录 /data/db。,终止”错误

运行“mongod”时出现“NonExistentPath: 未找到数据目录 /data/db。,终止”错误

我已经使用安装了 MongoDB

sudo apt-get install mongodb

Mongo shell 运行良好,但是当我mongod在终端中运行时,我得到了

2020-08-04T19:56:20.432+0400 I CONTROL  [initandlisten] MongoDB starting : pid=4079 port=27017 dbpath=/data/db 64-bit host=ideapad-15ikb
2020-08-04T19:56:20.432+0400 I CONTROL  [initandlisten] db version v3.6.8
2020-08-04T19:56:20.432+0400 I CONTROL  [initandlisten] git version: 8e540c0b6db93ce994cc548f000900bdc740f80a
2020-08-04T19:56:20.432+0400 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.1.1f  31 Mar 2020
2020-08-04T19:56:20.432+0400 I CONTROL  [initandlisten] allocator: tcmalloc
2020-08-04T19:56:20.432+0400 I CONTROL  [initandlisten] modules: none
2020-08-04T19:56:20.432+0400 I CONTROL  [initandlisten] build environment:
2020-08-04T19:56:20.432+0400 I CONTROL  [initandlisten]     distarch: x86_64
2020-08-04T19:56:20.432+0400 I CONTROL  [initandlisten]     target_arch: x86_64
2020-08-04T19:56:20.432+0400 I CONTROL  [initandlisten] options: {}
2020-08-04T19:56:20.433+0400 I STORAGE  [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
2020-08-04T19:56:20.433+0400 I CONTROL  [initandlisten] now exiting
2020-08-04T19:56:20.433+0400 I CONTROL  [initandlisten] shutting down with code:100

答案1

我所需要做的就是在根目录中创建新文件夹,sudo mkdir -p /data/db/然后运行此命令

sudo chown $(id -u) /data/db

相关内容