How to resolve featureCompatibilityVersion issue between MongoDB 3.6 and 4.2? - mongodb

I recently uninstalled MongoDB 3.6 and then installed MongoDB 4.2. When I navigated to MongoDB/Server/4.2/bin and executed mongo, I got the following error message:
$ mongod
2019-10-22T21:16:36.723-0400 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2019-10-22T21:16:37.217-0400 I CONTROL [initandlisten] MongoDB starting : pid=9376 port=27017 dbpath=C:\data\db\ 64-bit host=DESKTOP-LF34G1M
2019-10-22T21:16:37.217-0400 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2019-10-22T21:16:37.217-0400 I CONTROL [initandlisten] db version v4.2.1
2019-10-22T21:16:37.218-0400 I CONTROL [initandlisten] git version: edf6d45851c0b9ee15548f0f847df141764a317e
2019-10-22T21:16:37.218-0400 I CONTROL [initandlisten] allocator: tcmalloc
2019-10-22T21:16:37.218-0400 I CONTROL [initandlisten] modules: none
2019-10-22T21:16:37.218-0400 I CONTROL [initandlisten] build environment:
2019-10-22T21:16:37.218-0400 I CONTROL [initandlisten] distmod: 2012plus
2019-10-22T21:16:37.218-0400 I CONTROL [initandlisten] distarch: x86_64
2019-10-22T21:16:37.219-0400 I CONTROL [initandlisten] target_arch: x86_64
2019-10-22T21:16:37.219-0400 I CONTROL [initandlisten] options: {}
2019-10-22T21:16:37.230-0400 I STORAGE [initandlisten] Detected data files in C:\data\db\ created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wire
dTiger'.
2019-10-22T21:16:37.231-0400 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1498M,cache_overflow=(file_max=0M),session_max=33000,eviction=(threads_min=4,threa
ds_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000,close_scan_interval=10,close_handle
_minimum=250),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress],
2019-10-22T21:16:37.295-0400 I STORAGE [initandlisten] WiredTiger message [1571793397:294196][9376:140704250879568], txn-recover: Recovering log 22 through 23
2019-10-22T21:16:37.439-0400 I STORAGE [initandlisten] WiredTiger message [1571793397:438812][9376:140704250879568], txn-recover: Recovering log 23 through 23
2019-10-22T21:16:37.561-0400 I STORAGE [initandlisten] WiredTiger message [1571793397:560490][9376:140704250879568], txn-recover: Main recovery loop: starting at 22/896 to 23/256
2019-10-22T21:16:37.712-0400 I STORAGE [initandlisten] WiredTiger message [1571793397:712086][9376:140704250879568], txn-recover: Recovering log 22 through 23
2019-10-22T21:16:37.807-0400 I STORAGE [initandlisten] WiredTiger message [1571793397:806834][9376:140704250879568], txn-recover: Recovering log 23 through 23
2019-10-22T21:16:37.883-0400 I STORAGE [initandlisten] WiredTiger message [1571793397:882664][9376:140704250879568], txn-recover: Set global recovery timestamp: (0,0)
2019-10-22T21:16:37.934-0400 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2019-10-22T21:16:37.943-0400 I STORAGE [initandlisten] Timestamp monitor starting
2019-10-22T21:16:37.947-0400 I CONTROL [initandlisten]
2019-10-22T21:16:37.947-0400 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-10-22T21:16:37.948-0400 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2019-10-22T21:16:37.948-0400 I CONTROL [initandlisten]
2019-10-22T21:16:37.948-0400 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2019-10-22T21:16:37.948-0400 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2019-10-22T21:16:37.948-0400 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2019-10-22T21:16:37.949-0400 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2019-10-22T21:16:37.949-0400 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2019-10-22T21:16:37.949-0400 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2019-10-22T21:16:37.949-0400 I CONTROL [initandlisten]
2019-10-22T21:16:37.959-0400 I SHARDING [initandlisten] Marking collection local.system.replset as collection version: <unsharded>
2019-10-22T21:16:37.965-0400 F CONTROL [initandlisten] ** IMPORTANT: UPGRADE PROBLEM: Found an invalid featureCompatibilityVersion document (ERROR: BadValue: Invalid value for ver
sion, found 3.6, expected '4.2' or '4.0'. Contents of featureCompatibilityVersion document in admin.system.version: { _id: "featureCompatibilityVersion", version: "3.6" }. See http:
//dochub.mongodb.org/core/4.0-feature-compatibility.). If the current featureCompatibilityVersion is below 4.0, see the documentation on upgrading at http://dochub.mongodb.org/core/
4.0-upgrade-fcv.
2019-10-22T21:16:37.965-0400 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2019-10-22T21:16:37.966-0400 I - [initandlisten] Stopping further Flow Control ticket acquisitions.
2019-10-22T21:16:37.966-0400 I STORAGE [initandlisten] Deregistering all the collections
2019-10-22T21:16:37.966-0400 I STORAGE [initandlisten] Timestamp monitor shutting down
2019-10-22T21:16:37.967-0400 I STORAGE [initandlisten] WiredTigerKVEngine shutting down
2019-10-22T21:16:37.967-0400 I STORAGE [initandlisten] Shutting down session sweeper thread
2019-10-22T21:16:37.968-0400 I STORAGE [initandlisten] Finished shutting down session sweeper thread
2019-10-22T21:16:37.968-0400 I STORAGE [initandlisten] Shutting down journal flusher thread
2019-10-22T21:16:38.037-0400 I STORAGE [initandlisten] Finished shutting down journal flusher thread
2019-10-22T21:16:38.037-0400 I STORAGE [initandlisten] Shutting down checkpoint thread
2019-10-22T21:16:38.038-0400 I STORAGE [initandlisten] Finished shutting down checkpoint thread
2019-10-22T21:16:38.038-0400 I STORAGE [initandlisten] Downgrading WiredTiger datafiles.
2019-10-22T21:16:38.188-0400 I STORAGE [initandlisten] WiredTiger message [1571793398:187822][9376:140704250879568], txn-recover: Recovering log 23 through 24
2019-10-22T21:16:38.273-0400 I STORAGE [initandlisten] WiredTiger message [1571793398:272644][9376:140704250879568], txn-recover: Recovering log 24 through 24
2019-10-22T21:16:38.365-0400 I STORAGE [initandlisten] WiredTiger message [1571793398:365403][9376:140704250879568], txn-recover: Main recovery loop: starting at 23/2048 to 24/256
2019-10-22T21:16:38.533-0400 I STORAGE [initandlisten] WiredTiger message [1571793398:532944][9376:140704250879568], txn-recover: Recovering log 23 through 24
2019-10-22T21:16:38.642-0400 I STORAGE [initandlisten] WiredTiger message [1571793398:642615][9376:140704250879568], txn-recover: Recovering log 24 through 24
2019-10-22T21:16:38.722-0400 I STORAGE [initandlisten] WiredTiger message [1571793398:722405][9376:140704250879568], txn-recover: Set global recovery timestamp: (0,0)
2019-10-22T21:16:39.004-0400 I STORAGE [initandlisten] shutdown: removing fs lock...
2019-10-22T21:16:39.005-0400 I CONTROL [initandlisten] now exiting
2019-10-22T21:16:39.005-0400 I CONTROL [initandlisten] shutting down with code:62
The error which confuses me is:
UPGRADE PROBLEM: Found an invalid featureCompatibilityVersion document (ERROR: BadValue: Invalid value for version, found 3.6, expected '4.2' or '4.0'.
This does not seem to align with what I'm seeing below:
> db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
{ "featureCompatibilityVersion" : { "version" : "4.2" }, "ok" : 1 }
How am I able to fix this featureCompatibilityVersion issue?

The answer lies in the error message.
If the current featureCompatibilityVersion is below 4.0,
see the documentation on upgrading at
https://docs.mongodb.com/manual/release-notes/4.2/#upgrade-procedures
That page points out that if you have a version 3 installation, first you have to upgrade to 4.0. It doesn't help that on Macs, homebrew offers a mongodb-community installation that does not specify a version number. Currently, mongodb-community is 4.2.
What I did is:
brew services stop mongodb-community
brew uninstall mongodb-community
brew install mongodb-community#4.0
brew install mongodb-community-shell
brew services start mongodb-community#4.0
mongo
db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
[ it gave: { "featureCompatibilityVersion" : { "version" : "3.6" }, "ok" : 1 } ]
db.adminCommand( { setFeatureCompatibilityVersion: "4.0" } )
ctrl-c
brew services stop mongodb-community#4.0
brew uninstall mongodb-community#4.0
brew uninstall mongodb-community-shell [you get a new one with the next step]
brew install mongodb-community
brew services start mongodb-community
Which doesn't exactly trip off the tongue but did work for me without too much trouble.

My database directory, C:\data\db\, still existed from when 3.6 was running. The directory kept its state even after 3.6 was uninstalled, and was still configured for 3.6.
After clearing the directory, re-running mongod a second time did not produce any errors.

Quick 2023 update:
You can't install mongodb-community#4.0 via brew anymore, so my advice is:
Download the required version (4.0) from https://www.mongodb.com/try/download/community
Extract the files and run the binary bin/mongod directly from the extracted directory (you may need to grant permissions in your OS).
Once it's running, make the adjustments outlined here: https://www.mongodb.com/docs/manual/release-notes/4.2-upgrade-standalone/
Once you have completed the instructions from the link above, shutdown the server.
Now run your newer version of mongod, it should work ok.
Hope this saves time to some people.

Related

mongod fails to start with error message "missing UUID"

Mongod has been running as v4 for several months. It is used to record clinical data for patient with neurological diseases, and is essential to the drug trials.
This morning mongo crashed, and upon restarting, mongod refuses to start, on a collection that has a missing UUID. The message is cryptic, as this is not a 3.6 DB. Is there a way to proceed? The sensorTag collection is not really essential, and erasing it would be OK. Is there a way to get mongod to use the DB at all?
Here is the startup message:
2020-05-18T23:23:58.587+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-05-18T23:23:58.590+0000 I CONTROL [initandlisten] MongoDB starting : pid=1526 port=23417 dbpath=./db 64-bit host=retro-4-10-19
2020-05-18T23:23:58.590+0000 I CONTROL [initandlisten] db version v4.0.18
2020-05-18T23:23:58.590+0000 I CONTROL [initandlisten] git version: 6883bdfb8b8cff32176b1fd176df04da9165fd67
2020-05-18T23:23:58.590+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.1.1 11 Sep 2018
2020-05-18T23:23:58.590+0000 I CONTROL [initandlisten] allocator: tcmalloc
2020-05-18T23:23:58.590+0000 I CONTROL [initandlisten] modules: none
2020-05-18T23:23:58.590+0000 I CONTROL [initandlisten] build environment:
2020-05-18T23:23:58.590+0000 I CONTROL [initandlisten] distmod: ubuntu1804
2020-05-18T23:23:58.590+0000 I CONTROL [initandlisten] distarch: x86_64
2020-05-18T23:23:58.590+0000 I CONTROL [initandlisten] target_arch: x86_64
2020-05-18T23:23:58.590+0000 I CONTROL [initandlisten] options: { net: { bindIp: "127.0.0.1", port: 23417 }, storage: { dbPath: "./db" } }
2020-05-18T23:23:58.591+0000 I STORAGE [initandlisten] Detected data files in ./db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2020-05-18T23:23:58.591+0000 I STORAGE [initandlisten]
2020-05-18T23:23:58.591+0000 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2020-05-18T23:23:58.591+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2020-05-18T23:23:58.591+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=484M,cache_overflow=(file_max=0M),session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
2020-05-18T23:23:59.519+0000 I STORAGE [initandlisten] WiredTiger message [1589844239:519947][1526:0x7fa98a9fca40], txn-recover: Main recovery loop: starting at 46/768 to 47/256
2020-05-18T23:23:59.635+0000 I STORAGE [initandlisten] WiredTiger message [1589844239:635147][1526:0x7fa98a9fca40], txn-recover: Recovering log 46 through 47
2020-05-18T23:23:59.703+0000 I STORAGE [initandlisten] WiredTiger message [1589844239:703356][1526:0x7fa98a9fca40], txn-recover: Recovering log 47 through 47
2020-05-18T23:23:59.767+0000 I STORAGE [initandlisten] WiredTiger message [1589844239:767605][1526:0x7fa98a9fca40], txn-recover: Set global recovery timestamp: 0
2020-05-18T23:23:59.794+0000 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2020-05-18T23:23:59.807+0000 I CONTROL [initandlisten]
2020-05-18T23:23:59.807+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2020-05-18T23:23:59.807+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2020-05-18T23:23:59.807+0000 I CONTROL [initandlisten]
2020-05-18T23:23:59.823+0000 F CONTROL [initandlisten] ** IMPORTANT: Collection RetrotopeClinic.sensortags is missing an UUID. We expect all collections to have UUIDs starting in FCV 3.6. Please make sure the FCV is version 3.6 before attempting an upgrade to 4.0; see http://dochub.mongodb.org/core/4.0-upgrade-fcv for more details. If the FCV is already 3.6, please try --repair with a 3.6 binary or initial sync to fix the data files.
2020-05-18T23:23:59.823+0000 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2020-05-18T23:23:59.823+0000 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-23417.sock
2020-05-18T23:23:59.823+0000 I STORAGE [initandlisten] WiredTigerKVEngine shutting down
2020-05-18T23:23:59.823+0000 I STORAGE [initandlisten] Shutting down session sweeper thread
2020-05-18T23:23:59.823+0000 I STORAGE [initandlisten] Finished shutting down session sweeper thread
2020-05-18T23:23:59.901+0000 I STORAGE [initandlisten] Downgrading WiredTiger datafiles.
2020-05-18T23:24:00.088+0000 I STORAGE [initandlisten] WiredTiger message [1589844240:88483][1526:0x7fa98a9fca40], txn-recover: Main recovery loop: starting at 47/2176 to 48/256
2020-05-18T23:24:00.190+0000 I STORAGE [initandlisten] WiredTiger message [1589844240:190325][1526:0x7fa98a9fca40], txn-recover: Recovering log 47 through 48
2020-05-18T23:24:00.250+0000 I STORAGE [initandlisten] WiredTiger message [1589844240:250635][1526:0x7fa98a9fca40], txn-recover: Recovering log 48 through 48
2020-05-18T23:24:00.302+0000 I STORAGE [initandlisten] WiredTiger message [1589844240:302709][1526:0x7fa98a9fca40], txn-recover: Set global recovery timestamp: 0
2020-05-18T23:24:00.477+0000 I STORAGE [initandlisten] shutdown: removing fs lock...
2020-05-18T23:24:00.477+0000 I CONTROL [initandlisten] now exiting
2020-05-18T23:24:00.477+0000 I CONTROL [initandlisten] shutting down with code:62
I did also run with the --repair flag: it said it repaied the sensorTag collection, but no, it didn't, and still failed:
020-05-19T00:09:27.800+0000 I STORAGE [initandlisten] Repairing collection StagServExpress.sensortags
2020-05-19T00:09:27.801+0000 I STORAGE [initandlisten] Verify succeeded on uri table:collection-22-4256855214379632921. Not salvaging.
2020-05-19T00:09:27.805+0000 I INDEX [initandlisten] build index on: StagServExpress.sensortags properties: { v: 2, key: { _id: 1 }, name: "_id_", ns: "StagServExpress.sensortags" }
2020-05-19T00:09:27.806+0000 I INDEX [initandlisten] building index using bulk method; build may temporarily use up to 166 megabytes of RAM
2020-05-19T00:09:27.810+0000 I INDEX [initandlisten] build index on: StagServExpress.sensortags properties: { v: 2, unique: true, key: { UUID: 1 }, name: "UUID_1", ns: "StagServExpress.sensortags", background: true }
2020-05-19T00:09:27.810+0000 I INDEX [initandlisten] building index using bulk method; build may temporarily use up to 166 megabytes of RAM
2020-05-19T00:09:27.813+0000 I INDEX [initandlisten] build index on: StagServExpress.sensortags properties: { v: 2, key: { nickname: 1 }, name: "nickname_1", ns: "StagServExpress.sensortags", background: true }
2020-05-19T00:09:27.813+0000 I INDEX [initandlisten] building index using bulk method; build may temporarily use up to 166 megabytes of RAM
MongoDB 4.0.18 was released a month ago (April 13). You said:
Mongod has been running as v4 for several months.
Which version were you running for "several months" and how long have you been running 4.0.18 for?
Did you upgrade MongoDB at the same time as you experienced the crash?
Do you have backups?
Assuming you have a backup, reinstate the version of MongoDB that was in use prior to the crash and run it on the data directory as close to the crash as your backups allow.
The error message you are seeing was added in 4.0.13, so if you run 4.0.12 or earlier you shouldn't get this error (but I don't know if your data is corrupted and what other issues might exist).
Functionality does get backported to older versions, so it's possible there are older 4.0 servers that don't have the UUID that the current 4.0 is expecting because the changes were made in 4.0 (or 4.2) and backported to 3.6 but after 4.0.0 came out.

Mongod exits with error code: 62 when attempting to start mongod

I tried to start mongod and got this error
forked process: 4271
ERROR: child process failed, exited with error number 62
To see additional information in this output, start without the "--fork" option.
I retried with sudo mongod and got this instead
2019-11-26T12:54:27.563-0500 I CONTROL [initandlisten] MongoDB starting : pid=4275 port=27017 dbpath=/data/db 64-bit host=dhcp020-218-083.wireless.buffalo.edu
2019-11-26T12:54:27.563-0500 I CONTROL [initandlisten] db version v4.2.1
2019-11-26T12:54:27.563-0500 I CONTROL [initandlisten] git version: edf6d45851c0b9ee15548f0f847df141764a317e
2019-11-26T12:54:27.563-0500 I CONTROL [initandlisten] allocator: system
2019-11-26T12:54:27.563-0500 I CONTROL [initandlisten] modules: none
2019-11-26T12:54:27.563-0500 I CONTROL [initandlisten] build environment:
2019-11-26T12:54:27.563-0500 I CONTROL [initandlisten] distarch: x86_64
2019-11-26T12:54:27.563-0500 I CONTROL [initandlisten] target_arch: x86_64
2019-11-26T12:54:27.563-0500 I CONTROL [initandlisten] options: {}
2019-11-26T12:54:27.564-0500 I STORAGE [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2019-11-26T12:54:27.564-0500 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=7680M,cache_overflow=(file_max=0M),session_max=33000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000,close_scan_interval=10,close_handle_minimum=250),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress],
2019-11-26T12:54:28.082-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:81997][4275:0x114a835c0], txn-recover: Recovering log 35 through 36
2019-11-26T12:54:28.131-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:131917][4275:0x114a835c0], txn-recover: Recovering log 36 through 36
2019-11-26T12:54:28.180-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:180756][4275:0x114a835c0], txn-recover: Main recovery loop: starting at 35/896 to 36/256
2019-11-26T12:54:28.259-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:259184][4275:0x114a835c0], txn-recover: Recovering log 35 through 36
2019-11-26T12:54:28.306-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:306249][4275:0x114a835c0], txn-recover: Recovering log 36 through 36
2019-11-26T12:54:28.345-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:345839][4275:0x114a835c0], txn-recover: Set global recovery timestamp: (0,0)
2019-11-26T12:54:28.399-0500 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2019-11-26T12:54:28.405-0500 I STORAGE [initandlisten] Timestamp monitor starting
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten]
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten]
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten]
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten]
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2019-11-26T12:54:28.407-0500 I SHARDING [initandlisten] Marking collection local.system.replset as collection version: <unsharded>
2019-11-26T12:54:28.408-0500 F CONTROL [initandlisten] ** IMPORTANT: UPGRADE PROBLEM: Found an invalid featureCompatibilityVersion document (ERROR: BadValue: Invalid value for version, found 3.6, expected '4.2' or '4.0'. Contents of featureCompatibilityVersion document in admin.system.version: { _id: "featureCompatibilityVersion", version: "3.6" }. See http://dochub.mongodb.org/core/4.0-feature-compatibility.). If the current featureCompatibilityVersion is below 4.0, see the documentation on upgrading at http://dochub.mongodb.org/core/4.0-upgrade-fcv.
2019-11-26T12:54:28.408-0500 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2019-11-26T12:54:28.408-0500 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2019-11-26T12:54:28.408-0500 I - [initandlisten] Stopping further Flow Control ticket acquisitions.
2019-11-26T12:54:28.408-0500 I STORAGE [initandlisten] Deregistering all the collections
2019-11-26T12:54:28.408-0500 I STORAGE [initandlisten] Timestamp monitor shutting down
2019-11-26T12:54:28.408-0500 I STORAGE [initandlisten] WiredTigerKVEngine shutting down
2019-11-26T12:54:28.408-0500 I STORAGE [initandlisten] Shutting down session sweeper thread
2019-11-26T12:54:28.408-0500 I STORAGE [initandlisten] Finished shutting down session sweeper thread
2019-11-26T12:54:28.408-0500 I STORAGE [initandlisten] Shutting down journal flusher thread
2019-11-26T12:54:28.499-0500 I STORAGE [initandlisten] Finished shutting down journal flusher thread
2019-11-26T12:54:28.500-0500 I STORAGE [initandlisten] Shutting down checkpoint thread
2019-11-26T12:54:28.500-0500 I STORAGE [initandlisten] Finished shutting down checkpoint thread
2019-11-26T12:54:28.500-0500 I STORAGE [initandlisten] Downgrading WiredTiger datafiles.
2019-11-26T12:54:28.576-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:576019][4275:0x114a835c0], txn-recover: Recovering log 36 through 37
2019-11-26T12:54:28.615-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:615152][4275:0x114a835c0], txn-recover: Recovering log 37 through 37
2019-11-26T12:54:28.666-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:666135][4275:0x114a835c0], txn-recover: Main recovery loop: starting at 36/2048 to 37/256
2019-11-26T12:54:28.744-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:744560][4275:0x114a835c0], txn-recover: Recovering log 36 through 37
2019-11-26T12:54:28.790-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:790388][4275:0x114a835c0], txn-recover: Recovering log 37 through 37
2019-11-26T12:54:28.831-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:831263][4275:0x114a835c0], txn-recover: Set global recovery timestamp: (0,0)
2019-11-26T12:54:28.964-0500 I STORAGE [initandlisten] shutdown: removing fs lock...
2019-11-26T12:54:28.965-0500 I CONTROL [initandlisten] now exiting
2019-11-26T12:54:28.965-0500 I CONTROL [initandlisten] shutting down with code:62```
I already checked to see if I have a /data/db folder and I do, I tried to delete the data folder and recreate it with no luck. I checked on the forums and error code 62 means that the data/db folder is on a different version than the MongoDB installation, I'm not sure how I would go about fixing this error.

MongoDB 4.2 doesnt start on ubuntu 18.04 after reinstall - process immediately stops

I have problem with mongoDB - I going step by step with official tutorial:
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
Also I installed through this answer( of course I changed some commands to download 4.2 not 4.0 like it is in this answer): https://askubuntu.com/questions/842592/apt-get-fails-on-16-04-or-18-04-installing-mongodb/842599#842599
But afterall it still doesnt work:
adrian#ubuntu:~$ sudo service mongod start
adrian#ubuntu:~$ sudo service mongod status
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2019-09-26 09:37:53 CEST; 2s ago
Docs: https://docs.mongodb.org/manual
Process: 5220 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=62)
Main PID: 5220 (code=exited, status=62)
Sep 26 09:37:51 ubuntu systemd[1]: Started MongoDB Database Server.
Sep 26 09:37:53 ubuntu systemd[1]: mongod.service: Main process exited, code=exited, status=62/n/a
Sep 26 09:37:53 ubuntu systemd[1]: mongod.service: Failed with result 'exit-code'.
Even when I try to investigate mongo logs it still doesnt tell me much:
adrian#ubuntu:~$ sudo tail -n 100 /var/log/mongodb/mongod.log
2019-09-26T09:37:51.893+0200 I CONTROL [main] ***** SERVER RESTARTED *****
2019-09-26T09:37:51.895+0200 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2019-09-26T09:37:51.901+0200 I CONTROL [initandlisten] MongoDB starting : pid=5220 port=27017 dbpath=/var/lib/mongodb 64-bit host=ubuntu
2019-09-26T09:37:51.901+0200 I CONTROL [initandlisten] db version v4.2.0
2019-09-26T09:37:51.901+0200 I CONTROL [initandlisten] git version: a4b751dcf51dd249c5865812b390cfd1c0129c30
2019-09-26T09:37:51.901+0200 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.1.1 11 Sep 2018
2019-09-26T09:37:51.901+0200 I CONTROL [initandlisten] allocator: tcmalloc
2019-09-26T09:37:51.901+0200 I CONTROL [initandlisten] modules: none
2019-09-26T09:37:51.901+0200 I CONTROL [initandlisten] build environment:
2019-09-26T09:37:51.901+0200 I CONTROL [initandlisten] distmod: ubuntu1804
2019-09-26T09:37:51.901+0200 I CONTROL [initandlisten] distarch: x86_64
2019-09-26T09:37:51.901+0200 I CONTROL [initandlisten] target_arch: x86_64
2019-09-26T09:37:51.901+0200 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, processManagement: { timeZoneInfo: "/usr/share/zoneinfo" }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2019-09-26T09:37:51.901+0200 I STORAGE [initandlisten] Detected data files in /var/lib/mongodb created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2019-09-26T09:37:51.901+0200 I STORAGE [initandlisten]
2019-09-26T09:37:51.901+0200 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2019-09-26T09:37:51.901+0200 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2019-09-26T09:37:51.901+0200 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=11527M,cache_overflow=(file_max=0M),session_max=33000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress],
2019-09-26T09:37:52.400+0200 I STORAGE [initandlisten] WiredTiger message [1569483472:400536][5220:0x7fc6c8d05b00], txn-recover: Recovering log 20 through 21
2019-09-26T09:37:52.460+0200 I STORAGE [initandlisten] WiredTiger message [1569483472:460670][5220:0x7fc6c8d05b00], txn-recover: Recovering log 21 through 21
2019-09-26T09:37:52.544+0200 I STORAGE [initandlisten] WiredTiger message [1569483472:544472][5220:0x7fc6c8d05b00], txn-recover: Main recovery loop: starting at 20/896 to 21/256
2019-09-26T09:37:52.607+0200 I STORAGE [initandlisten] WiredTiger message [1569483472:607556][5220:0x7fc6c8d05b00], txn-recover: Recovering log 20 through 21
2019-09-26T09:37:52.643+0200 I STORAGE [initandlisten] WiredTiger message [1569483472:643077][5220:0x7fc6c8d05b00], txn-recover: Recovering log 21 through 21
2019-09-26T09:37:52.669+0200 I STORAGE [initandlisten] WiredTiger message [1569483472:669301][5220:0x7fc6c8d05b00], txn-recover: Set global recovery timestamp: (0,0)
2019-09-26T09:37:52.677+0200 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2019-09-26T09:37:52.682+0200 I STORAGE [initandlisten] Timestamp monitor starting
2019-09-26T09:37:52.683+0200 I CONTROL [initandlisten]
2019-09-26T09:37:52.683+0200 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-09-26T09:37:52.684+0200 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2019-09-26T09:37:52.684+0200 I CONTROL [initandlisten]
2019-09-26T09:37:52.698+0200 I SHARDING [initandlisten] Marking collection local.system.replset as collection version: <unsharded>
2019-09-26T09:37:52.698+0200 F CONTROL [initandlisten] ** IMPORTANT: UPGRADE PROBLEM: Found an invalid featureCompatibilityVersion document (ERROR: BadValue: Invalid value for version, found 3.6, expected '4.2' or '4.0'. Contents of featureCompatibilityVersion document in admin.system.version: { _id: "featureCompatibilityVersion", version: "3.6" }. See http://dochub.mongodb.org/core/4.0-feature-compatibility.). If the current featureCompatibilityVersion is below 4.0, see the documentation on upgrading at http://dochub.mongodb.org/core/4.0-upgrade-fcv.
2019-09-26T09:37:52.698+0200 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2019-09-26T09:37:52.698+0200 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2019-09-26T09:37:52.698+0200 I - [initandlisten] Stopping further Flow Control ticket acquisitions.
2019-09-26T09:37:52.698+0200 I STORAGE [initandlisten] Deregistering all the collections
2019-09-26T09:37:52.698+0200 I STORAGE [initandlisten] Timestamp monitor shutting down
2019-09-26T09:37:52.698+0200 I STORAGE [initandlisten] WiredTigerKVEngine shutting down
2019-09-26T09:37:52.699+0200 I STORAGE [initandlisten] Shutting down session sweeper thread
2019-09-26T09:37:52.699+0200 I STORAGE [initandlisten] Finished shutting down session sweeper thread
2019-09-26T09:37:52.699+0200 I STORAGE [initandlisten] Shutting down journal flusher thread
2019-09-26T09:37:52.779+0200 I STORAGE [initandlisten] Finished shutting down journal flusher thread
2019-09-26T09:37:52.779+0200 I STORAGE [initandlisten] Shutting down checkpoint thread
2019-09-26T09:37:52.779+0200 I STORAGE [initandlisten] Finished shutting down checkpoint thread
2019-09-26T09:37:52.779+0200 I STORAGE [initandlisten] Downgrading WiredTiger datafiles.
2019-09-26T09:37:52.808+0200 I STORAGE [initandlisten] WiredTiger message [1569483472:808033][5220:0x7fc6c8d05b00], txn-recover: Recovering log 21 through 22
2019-09-26T09:37:52.848+0200 I STORAGE [initandlisten] WiredTiger message [1569483472:848763][5220:0x7fc6c8d05b00], txn-recover: Recovering log 22 through 22
2019-09-26T09:37:52.891+0200 I STORAGE [initandlisten] WiredTiger message [1569483472:891333][5220:0x7fc6c8d05b00], txn-recover: Main recovery loop: starting at 21/3328 to 22/256
2019-09-26T09:37:52.944+0200 I STORAGE [initandlisten] WiredTiger message [1569483472:944712][5220:0x7fc6c8d05b00], txn-recover: Recovering log 21 through 22
2019-09-26T09:37:52.977+0200 I STORAGE [initandlisten] WiredTiger message [1569483472:977288][5220:0x7fc6c8d05b00], txn-recover: Recovering log 22 through 22
2019-09-26T09:37:53.003+0200 I STORAGE [initandlisten] WiredTiger message [1569483473:3143][5220:0x7fc6c8d05b00], txn-recover: Set global recovery timestamp: (0,0)
2019-09-26T09:37:53.023+0200 I STORAGE [initandlisten] shutdown: removing fs lock...
2019-09-26T09:37:53.023+0200 I CONTROL [initandlisten] now exiting
2019-09-26T09:37:53.023+0200 I CONTROL [initandlisten] shutting down with code:62
I will be very grateful for any advice
Remove complete mongodb from your ubuntu
sudo apt-get purge mongo* // or sudo apt remove mongo*
sudo apt-get purge mongodb-org*
Backup your database and remove log and data using folder
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb
Now install again with this
$ wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc \
sudo apt-key add -
Add sources
$ echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.2 multiverse" \
sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list
Then install mongodb package again
sudo apt-get install -y mongodb-org=4.2.0 \
mongodb-org-server=4.2.0 \
mongodb-org-shell=4.2.0 \
mongodb-org-mongos=4.2.0 \
mongodb-org-tools=4.2.0
Start service using mongodb
$ systemctl enable mongod.service
$ sudo service mongod start
Or Follow this doc installation process
i also have this issue, i solved by change the bindIp in mongo config
On Linux, a default /etc/mongod.conf configuration file is included
when using a package manager to install MongoDB.
sudo nano /etc/mongod.conf
then edit the bindIP to
bindIp: [127.0.0.1, X.X.X.X]
Then restart mongodb .
sudo service mongod stop
sudo service mongod start

MongoDB server running, I get "mongo: command not found"

I`ve started mongoDB and it seems like its running fine, I think (see message below)? Then I open a new terminal window and I try to use the "mongo" command I get the following message:
-bash: mongo: command not found
When I try commands such as "use newtest", it says
-bash: use: command not found
My Path:
PATH=/Users/myname/.npm-global/bin:$PATH
Here is the message when I start mongoDB:
myname-MacBook-Air:~ myname$ mongod
I CONTROL [initandlisten] MongoDB starting : pid=581 port=27017 dbpath=/data/db 64-bit host=myname-MacBook-Air.local
I CONTROL [initandlisten] db version v3.6.2
I CONTROL [initandlisten] git version: 489d177dbd0f0420a8ca04d39fd78d0a2c539420
I CONTROL [initandlisten] OpenSSL version: OpenSSL 0.9.8zh 14 Jan 2016
I CONTROL [initandlisten] allocator: system
I CONTROL [initandlisten] modules: none
I CONTROL [initandlisten] build environment:
I CONTROL [initandlisten] distarch: x86_64
I CONTROL [initandlisten] target_arch: x86_64
I CONTROL [initandlisten] options: {}
W - [initandlisten] Detected unclean shutdown - /data/db/mongod.lock is not empty.
I - [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
W STORAGE [initandlisten] Recovering data from the last clean checkpoint.
I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=3584M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
I STORAGE [initandlisten] WiredTiger message [1519475976:405758][581:0x7fff95b02340], txn-recover: Main recovery loop: starting at 4/3200
I STORAGE [initandlisten] WiredTiger message [1519475976:408878][581:0x7fff95b02340], txn-recover: Recovering log 4 through 5
I STORAGE [initandlisten] WiredTiger message [1519475976:564148][581:0x7fff95b02340], txn-recover: Recovering log 5 through 5
I CONTROL [initandlisten]
I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
I CONTROL [initandlisten]
I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
I CONTROL [initandlisten]
I CONTROL [initandlisten]
I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
I NETWORK [initandlisten] waiting for connections on port 27017
I FTDC [ftdc] Unclean full-time diagnostic data capture shutdown detected, found interim file, some metrics may have been lost. OK
What am I doing wrong here to start mongodB? Or am I misunderstanding it?
Thanks :)

Mongod error (installed with homebrew)

I have installed mongodb with
brew install mongodb
Created folder
mkdir -p /data/db
Handle permissions
sudo chown -R `id -un` /data/db
Run
mongod
Error log
2018-01-06T14:28:51.450+0100 I CONTROL [initandlisten] MongoDB starting : pid=6120 port=27017 dbpath=/data/db 64-bit host=Zigas-MBP-2
2018-01-06T14:28:51.451+0100 I CONTROL [initandlisten] db version v3.6.1
2018-01-06T14:28:51.451+0100 I CONTROL [initandlisten] git version: 025d4f4fe61efd1fb6f0005be20cb45a004093d1
2018-01-06T14:28:51.451+0100 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2n 7 Dec 2017
2018-01-06T14:28:51.451+0100 I CONTROL [initandlisten] allocator: system
2018-01-06T14:28:51.451+0100 I CONTROL [initandlisten] modules: none
2018-01-06T14:28:51.451+0100 I CONTROL [initandlisten] build environment:
2018-01-06T14:28:51.451+0100 I CONTROL [initandlisten] distarch: x86_64
2018-01-06T14:28:51.451+0100 I CONTROL [initandlisten] target_arch: x86_64
2018-01-06T14:28:51.451+0100 I CONTROL [initandlisten] options: {}
2018-01-06T14:28:51.452+0100 I - [initandlisten] Detected data files in /data/db created by the 'mmapv1' storage engine, so setting the active storage engine to 'mmapv1'.
2018-01-06T14:28:51.470+0100 I JOURNAL [initandlisten] journal dir=/data/db/journal
2018-01-06T14:28:51.471+0100 I JOURNAL [initandlisten] recover : no journal files present, no recovery needed
2018-01-06T14:28:51.494+0100 I JOURNAL [durability] Durability thread started
2018-01-06T14:28:51.494+0100 I JOURNAL [journal writer] Journal writer thread started
2018-01-06T14:28:51.495+0100 I CONTROL [initandlisten]
2018-01-06T14:28:51.495+0100 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-01-06T14:28:51.495+0100 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2018-01-06T14:28:51.495+0100 I CONTROL [initandlisten]
2018-01-06T14:28:51.495+0100 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2018-01-06T14:28:51.495+0100 I CONTROL [initandlisten] ** Remote systems will be unable toconnect to this server.
2018-01-06T14:28:51.495+0100 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2018-01-06T14:28:51.495+0100 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2018-01-06T14:28:51.495+0100 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2018-01-06T14:28:51.495+0100 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2018-01-06T14:28:51.495+0100 I CONTROL [initandlisten]
2018-01-06T14:28:51.762+0100 F CONTROL [initandlisten] ** IMPORTANT: UPGRADE PROBLEM: The data files need to be fully upgraded to version 3.4 before attempting an upgrade to 3.6; see http://dochub.mongodb.org/core/3.6-upgrade-fcv for more details.
2018-01-06T14:28:51.762+0100 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2018-01-06T14:28:51.763+0100 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2018-01-06T14:28:51.763+0100 I REPL [initandlisten] shutdown: removing all drop-pending collections...
2018-01-06T14:28:51.763+0100 I REPL [initandlisten] shutdown: removing checkpointTimestamp collection...
2018-01-06T14:28:51.763+0100 I STORAGE [initandlisten] shutdown: waiting for fs preallocator...
2018-01-06T14:28:51.763+0100 I STORAGE [initandlisten] shutdown: final commit...
2018-01-06T14:28:51.770+0100 I JOURNAL [initandlisten] journalCleanup...
2018-01-06T14:28:51.770+0100 I JOURNAL [initandlisten] removeJournalFiles
2018-01-06T14:28:51.770+0100 I JOURNAL [initandlisten] old journal file will be removed: /data/db/journal/j._0
2018-01-06T14:28:51.771+0100 I JOURNAL [initandlisten] Terminating durability thread ...
2018-01-06T14:28:51.870+0100 I JOURNAL [journal writer] Journal writer thread stopped
2018-01-06T14:28:51.870+0100 I JOURNAL [durability] Durability thread stopped
2018-01-06T14:28:51.870+0100 I STORAGE [initandlisten] shutdown: closing all files...
2018-01-06T14:28:51.883+0100 I STORAGE [initandlisten] closeAllFiles() finished
2018-01-06T14:28:51.883+0100 I STORAGE [initandlisten] shutdown: removing fs lock...
2018-01-06T14:28:51.883+0100 I CONTROL [initandlisten] now exiting
2018-01-06T14:28:51.883+0100 I CONTROL [initandlisten] shutting down with code:62
Any help would be apprichiated.
2018-01-06T14:28:51.762+0100 F CONTROL [initandlisten] ** IMPORTANT: UPGRADE PROBLEM: The data files need to be fully upgraded to version 3.4 before attempting an upgrade to 3.6; see http://dochub.mongodb.org/core/3.6-upgrade-fcv for more details.
This is the fault error in your log.
So I guess you have some 3.4 data in your /data/db.
If you want a clean installation, just remove the contents of /data/db and restart mongod
or
Get a 3.4 mongod
Ref: https://docs.mongodb.com/manual/release-notes/3.6-upgrade-standalone/
The error is telling you that you have mongo 3.4 data inside /data/db but you have version 3.6 of Mongo installed.
To fix this you can use one of the options listed below...
Remove the contents of /data/db and restart mongod. This should probably be backed up or you'll lose your data.
Install mongodb 3.4 you can check if you previously installed it using brew list --versions mongodb then if a 3.4.* version comes up, 3.4.10 for example use brew switch mongodb 3.4.10 to move back to that version. If you never had the version installed see this answer to install the older version Homebrew install specific version of formula?
Use #2 to move back to 3.4 then go into mongo shell using mongo and run db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } ). Exit the mongo shell and use the brew switch command to switch back to 3.6.