Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve error :dbpath (/data/db/) does not exist permanently in MongoDB

Tags:

mongodb

ubuntu

I have installed mongodb in my Ubuntu 10.04.

I know that when it comes to start the mongodb server with the command "mongod",then it expects /data/db folder and it can be easily resolved by creating "/data/db/". One more way is to provide your own path using mongod --dbpath "path",when we intend to give our own custom path for db.

But while going through http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/ link i found that there is a configuration file.

I made the following changes to it.

# mongodb.conf

dbpath=/EBS/Work/mongodb/data/db/   logpath=/EBS/Work/mongodb/mongodb.log  logappend=true 

But still when I try to start the server with "mongod" it throws the same error i.e error :dbpath (/data/db/) does not exist . I wanted to know that how can I permanently redirect my dbpath to my own custom folder cause everytime you don't want to type the path using "mongod --dbpath path".Rather we look to make some changes in configuration file.

like image 516
Abhinav Avatar asked Sep 13 '12 06:09

Abhinav


People also ask

Where is Mongodb database stored in Ubuntu?

By default, mongod sets the database location to /data/db/. For checking by yourself you should run ps -xa | grep mongod and if you don't see a --dbpath which explicitly tells mongod to look at that parameter for the db location and you don't have a dbpath in your mongodb.


1 Answers

Assuming you have followed the instructions to install a packaged version of MongoDB, you should be starting and stopping mongod using service.

To start mongod:

 sudo service mongodb start 

To stop mongod:

 sudo service mongodb stop 

If you use the service command to start and stop, it should be using the configuration file: /etc/mongodb.conf.

Starting mongod from the command line

If you run mongod directly instead of using the service definition, you will also have to specify a configuration file as a command line parameter if you want one to be used:

mongod --config /etc/mongodb.conf 
like image 179
Stennie Avatar answered Sep 29 '22 17:09

Stennie