问题描述:
解决方案:
1.查看保存数据库的目录是否存在
ls -ld /data/db
执行结果如下:
cuigaochongdeMacBook-Pro:~ root# ls -ld /data/db
drwxr-xr-x 7 root wheel 238 Sep 24 16:21 /data/db
2.启动MongoDB的同时指定数据库保存在什么地方
mongod --dbpath /data/db
执行结果如下:
cuigaochongdeMacBook-Pro:~ root# mongod --dbpath /data/db
2016-09-24T16:37:28.410+0800 I JOURNAL [initandlisten] journal dir=/data/db/journal
2016-09-24T16:37:28.410+0800 I JOURNAL [initandlisten] recover : no journal files present, no recovery needed
2016-09-24T16:37:28.422+0800 I JOURNAL [durability] Durability thread started
2016-09-24T16:37:28.422+0800 I CONTROL [initandlisten] MongoDB starting : pid=624 port=27017 dbpath=/data/db 64-bit host=cuigaochongdeMacBook-Pro.local
2016-09-24T16:37:28.422+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2016-09-24T16:37:28.422+0800 I JOURNAL [journal writer] Journal writer thread started
2016-09-24T16:37:28.422+0800 I CONTROL [initandlisten]
2016-09-24T16:37:28.422+0800 I CONTROL [initandlisten]
2016-09-24T16:37:28.422+0800 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2016-09-24T16:37:28.422+0800 I CONTROL [initandlisten] db version v3.0.7
2016-09-24T16:37:28.422+0800 I CONTROL [initandlisten] git version: nogitversion
2016-09-24T16:37:28.422+0800 I CONTROL [initandlisten] build info: Darwin yosemitevm.local 14.5.0 Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
2016-09-24T16:37:28.422+0800 I CONTROL [initandlisten] allocator: system
2016-09-24T16:37:28.422+0800 I CONTROL [initandlisten] options: { storage: { dbPath: "/data/db" } }
2016-09-24T16:37:28.431+0800 I NETWORK [initandlisten] waiting for connections on port 27017
3.再次执行mongo
cuigaochongdeMacBook-Pro:~ cuigaochong$ mongo
MongoDB shell version: 3.0.7
connecting to: test
Server has startup warnings:
2016-09-24T16:31:54.576+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2016-09-24T16:31:54.576+0800 I CONTROL [initandlisten]
2016-09-24T16:31:54.576+0800 I CONTROL [initandlisten]
2016-09-24T16:31:54.576+0800 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
>
成功
本文出自 “云人生” 博客,请务必保留此出处http://ovcer.blog.51cto.com/1145188/1416906