title: How to discover MongoDB's data directory?
body: <p>I know <code>mongod --dbpath &lt;mypath&gt;</code> will <em>assign</em> the directory. Is there a quick command-line way to spit out its path?</p>
  
  <p>After all my data were supposedly migrated to a new laptop from my old one, I'm just trying to plug back into that old directory. I don't remember if it was <strong>/data/db</strong> or somewhere custom, but when I got the machine back, there was no <strong>/data/db</strong>.</p>
  
  <p>Right now, when I try to start this new mongo installation I get:</p>
  
  <pre><code>I STORAGE  [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
  I CONTROL  [initandlisten] dbexit:  rc: 100
  </code></pre>
  
  <p>I didn't have a <strong>mongo.conf</strong> file before, but if there's no way to discover the old directory, seems like I should make one now, if for no other reason than to have a record of it.</p>
  
  <p>Kinda hard to believe there's not a simple command or environment variable or something for this.</p>