I'm using mongodb in a project. I shut down mongodb and when I restarted mongodb all my databases and collections were gone. How do I figure out what happened?
In order to find the files, you can check the db path. You can do this by using
grep dbPath /etc/mongod.conf
(on default installations). This should return a line with the path to the files.
If the first command does not work, you can use the command
ps aux | grep mongo
and search for the mongod process. There should be something like this on the output:
/usr/bin/mongod --config /etc/mongod.conf
If there is a --dbpath argument on the process, you should look there for the files.
And in case your files are not in the dbpath fodler, the last resource I can think of is searching for the files on the whole file system:
sudo find / -name 'mongo*'
(you should find the mongod.lock
file in the folders that were already used by Mongo).
If you happen to find your files in another folder that is not being used by Mongo, then you'll have to change the dbPath on config.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.