3

I use MongoDB on multiple production servers, with different versions for different projects. My development environment has v3.6 of the shell but when I connect to a server with MongoDB v3.4, I am greeted with this message upon login:

WARNING: shell and server versions do not match

Is it unsafe to use a newer Mongo shell with an older DB version? Has MongoDB provided any official answer/documentation regarding this?

TheKarateKid
  • 772
  • 11
  • 19

1 Answers1

2

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.

Stennie
  • 63,885
  • 14
  • 149
  • 175