zardon
zardon

Reputation: 2920

How do I force save the dbpath parameter?

I'm just starting out with developing with Mongodb locally and following the tutorials.

I want to use 1 path for all my development.

In the Mongodb documentation it says:

Create a data directory

By default MongoDB will store data in /data/db, but it won't automatically create that directory. To create it, do:

$ mkdir -p /data/db

You can also tell MongoDB to use a different data directory, with the --dbpath option.

I want to use one path for all my dbpaths so that I know where they all are and not get confused.

The path I want to use is:

sudo mongod --config=/Applications/XAMPP/xamppfiles/var/mongodb/mongodb.conf 

The mongodb.conf file I have is set up as thus:

# Store data alongside MongoDB instead of the default, /data/db/
dbpath = /Applications/XAMPP/xamppfiles/var/mongodb

# Only accept local connections
bind_ip = 127.0.0.1

However, I have noticed that I have to keep typing this config path in every time I want to run Mongo.

How do I make it so that Mongodb save the dbpath, or the path to the config without me having to type it out every time?

Thanks.

Upvotes: 0

Views: 2809

Answers (2)

Scott Hernandez
Scott Hernandez

Reputation: 7590

You can create a startup script, like a bash/cshc script. You must specify those options when starting up.

Upvotes: 2

Bryan Migliorisi
Bryan Migliorisi

Reputation: 9210

Make a bash script that runs the commands you want.

Make a file called startMongo.sh

#! /bin/bash
mongod --config=/Applications/XAMPP/xamppfiles/var/mongodb/mongodb.conf

Run command

sudo startMongo.sh

Upvotes: 1

Related Questions