title: How do I change mongodb data directory on windows
body: <p>My MongoDB server was running fine until yesterday. But then I encountered this error:</p>
  
  <pre><code>2020-03-31T10:21:25.981+0530 I  CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
  2020-03-31T10:21:25.986+0530 I  CONTROL  [initandlisten] MongoDB starting : pid=7544 port=27017 dbpath=C:\data\db\ 64-bit host=DESKTOP-IP084D8
  2020-03-31T10:21:25.987+0530 I  CONTROL  [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
  2020-03-31T10:21:25.987+0530 I  CONTROL  [initandlisten] db version v4.2.3
  2020-03-31T10:21:25.987+0530 I  CONTROL  [initandlisten] git version: 6874650b362138df74be53d366bbefc321ea32d4
  2020-03-31T10:21:25.987+0530 I  CONTROL  [initandlisten] allocator: tcmalloc
  2020-03-31T10:21:25.987+0530 I  CONTROL  [initandlisten] modules: none
  2020-03-31T10:21:25.987+0530 I  CONTROL  [initandlisten] build environment:
  2020-03-31T10:21:25.987+0530 I  CONTROL  [initandlisten]     distmod: 2012plus
  2020-03-31T10:21:25.987+0530 I  CONTROL  [initandlisten]     distarch: x86_64
  2020-03-31T10:21:25.987+0530 I  CONTROL  [initandlisten]     target_arch: x86_64
  2020-03-31T10:21:25.988+0530 I  CONTROL  [initandlisten] options: {}
  2020-03-31T10:21:25.990+0530 I  STORAGE  [initandlisten] exception in initAndListen: NonExistentPath: Data directory C:\data\db\ not found., terminating
  2020-03-31T10:21:25.990+0530 I  NETWORK  [initandlisten] shutdown: going to close listening sockets...
  2020-03-31T10:21:25.990+0530 I  -        [initandlisten] Stopping further Flow Control ticket acquisitions.
  2020-03-31T10:21:25.990+0530 I  CONTROL  [initandlisten] now exiting
  2020-03-31T10:21:25.991+0530 I  CONTROL  [initandlisten] shutting down with code:100
  </code></pre>
  
  <p>I do not know how the data path got changed. I have to change the MongoDB data path from <code>C:\data\db\</code> to <code>C:\Program Files\MongoDB\Server\4.2\data</code>, so I tried changing it using the following command, but it doesn't recognize the path:</p>
  
  <p><code>mongod --dbpath C:\Program Files\MongoDB\Server\4.2\data</code></p>
  
  <p>What should be the format of the path to be entered here?</p>