我有一个简单的bash脚本来运行mongodb:
#!/bin/bash
sudo mongod --dbpath data/db
echo "Mongo is running!"
在终端中,我执行:
。 ./mongo.sh
我确信该目录是正确的,并且我已经将我的权限CHMOD到751,所以我应该能够执行该脚本。但相反,我得到了这个错误:
2016-08-28T16:15:15.311-0400 I CONTROL [initandlisten] allocator: system
2016-08-28T16:15:15.311-0400 I CONTROL [initandlisten] modules: none
2016-08-28T16:15:15.311-0400 I CONTROL [initandlisten] build environment:
2016-08-28T16:15:15.311-0400 I CONTROL [initandlisten] distarch: x86_64
2016-08-28T16:15:15.311-0400 I CONTROL [initandlisten] target_arch: x86_64
2016-08-28T16:15:15.311-0400 I CONTROL [initandlisten] options: { storage: { dbPath: "data/db" } }
2016-08-28T16:15:15.312-0400 I STORAGE [initandlisten] exception in initAndListen: 29 Data directory data/db not found., terminating
2016-08-28T16:15:15.312-0400 I CONTROL [initandlisten] dbexit: rc: 100
Mongo is running!
当我运行" mongod --dbpath data / db"在shell窗口中,命令执行没有问题所以我做错了什么?
答案 0 :(得分:1)
我建议添加data/db
的完整路径。