Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to find mongod.conf file in ubuntu

Tags:

mongodb

I want to change auth=false to auth=true in mongod.conf file in ubuntu but not able to find mongod.conf file in /etc/. So which are the other possible locations for finding this file.

like image 724
prabodhtiwari Avatar asked Dec 13 '15 08:12

prabodhtiwari


People also ask

Where are MongoDB files stored Linux?

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.

What is the name of the default file used to configure MongoDB?

dbPath is /var/lib/mongodb; this setting specifies where MongoDB should store its files.


4 Answers

Finding your mongod config path using mongo shell:

db.adminCommand('getCmdLineOpts');

It returns all command line options. Just for config path:

db.adminCommand('getCmdLineOpts').parsed.config;

Reference: https://docs.mongodb.org/manual/reference/command/getCmdLineOpts/

--

You can create manually. Path: /etc/mongod.conf

Also take a look https://docs.mongodb.org/v3.0/reference/configuration-options/#use-the-configuration-file

like image 152
hisener Avatar answered Oct 03 '22 18:10

hisener


In my case Ubuntu 18.04: /etc/mongodb.conf

like image 45
Chris Avatar answered Oct 03 '22 20:10

Chris


Still got this in 2020. reinstalling all mongodb-related packages solved it for me

apt purge mongo*
apt install mongodb

Note that simply reinstalling just mongodb package doesn't fix it.

like image 20
ezekiel87 Avatar answered Oct 03 '22 18:10

ezekiel87


In a terminal run sudo find / -name mongodb.conf (I'm aware that the OP looks for mongod.conf, not sure if this is a typo? No such file on my system...)

like image 39
mjkrause Avatar answered Oct 03 '22 19:10

mjkrause