first of all, according to the description of the official document, the configuration file is created and the database path is modified. The content of the configuration file mongo.config
is as follows:
systemLog:
destination: file
path: I:\mongodb_data\log\mongod.log
logAppend: false
storage:
dbPath: I:\mongodb_data\db
net:
port: 27017
bindIp: 127.0.0.1
then customize the mongodb service with the following command:
mongod --config "C:\\Program Files\\MongoDB\\Server\\3.6\\mongo.config" --install
then restart the mongdb service, but after opening mongod, it is found that the database path is still on disk C, as follows:
C:\Program Files\MongoDB\Server\3.6\bin>mongod
2018-03-26T23:33:52.760-0700 I CONTROL [initandlisten] MongoDB starting : pid=29408 port=27017 dbpath=C:\data\db\ 64-bit host=LAPTOP-5EHTU72R
2018-03-26T23:33:52.760-0700 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2018-03-26T23:33:52.761-0700 I CONTROL [initandlisten] db version v3.6.3
2018-03-26T23:33:52.763-0700 I CONTROL [initandlisten] git version: 9586e557d54ef70f9ca4b43c26892cd55257e1a5
2018-03-26T23:33:52.764-0700 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1u-fips 22 Sep 2016
2018-03-26T23:33:52.766-0700 I CONTROL [initandlisten] allocator: tcmalloc
2018-03-26T23:33:52.767-0700 I CONTROL [initandlisten] modules: none
2018-03-26T23:33:52.769-0700 I CONTROL [initandlisten] build environment:
2018-03-26T23:33:52.771-0700 I CONTROL [initandlisten] distmod: 2008plus-ssl
2018-03-26T23:33:52.773-0700 I CONTROL [initandlisten] distarch: x86_64
2018-03-26T23:33:52.774-0700 I CONTROL [initandlisten] target_arch: x86_64
2018-03-26T23:33:52.776-0700 I CONTROL [initandlisten] options: {}
2018-03-26T23:33:52.778-0700 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory C:\data\db\ not found., terminating
2018-03-26T23:33:52.779-0700 I CONTROL [initandlisten] now exiting
2018-03-26T23:33:52.782-0700 I CONTROL [initandlisten] shutting down with code:100
Why is the configuration file invalid? I did it completely according to the official documents