Is it unsafe to use a newer Mongo shell with an older DB version?
The startup warning is about expectations rather than safety: ideally the major version (x.y
) of your mongo
shell and MongoDB deployment should be part of the same release series. Basic commands are generally backward-compatible (and will default to "legacy mode" where appropriate), but mismatched shell versions can definitely lead to unexpected or confusing results.
For example, the 3.6 mongo
shell includes helpers for new MongoDB 3.6 features like sessions and retryable writes. If you connect to an older MongoDB server, use of helpers for newer features or options may not always result in an obvious error or warning.
Similarly, if you connect to a MongoDB 3.6 deployment using a 3.4 mongo
shell you will be missing helpers for newer server features.
You can choose to ignore the version mismatch warning if you are confident the difference won't cause any issues for the commands you are using.
If you regularly need to connect to multiple MongoDB server versions (and use Linux or macOS), m (MongoDB version manager) is very handy for downloading and switching between multiple mongo
versions.