mongoexport could not connect to server with username issue

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Environment:
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      Problem Statement/Rationale

      running follow command

      ```
      mongoexport --host dbhost --port 27017 --db=mms-service --collection=document --type=csv --fields=_id --query='{}' --limit 10 --out exported.csv -u=user.name --authenticationDatabase admin
      ```

      but i get an error

      ```
      could not connect to server: connection() error occured during connection handshake: handshake failure: username must contain a '.' separated database.user pair
      ```

      what is the meaning of the error, it is the issue of the username, a dot in the username?

      i also try to add quote to the username: "user.name", 'user.name', same error

       

      Steps to Reproduce

      use mongo/mongoexport to connect to the db

      Expected Results

      login the db successfully

      Actual Results

      login failed

      Additional Notes

      1, also try mongo command, same error
      ```
      mongo "mongodb://user.name:password@db-host:27017/?authSource=admin"

      mongo --host dbhost --port 27017 -u user.name -p password --authenticationDatabase admin
      ```
      error message:
      ```
      MongoDB shell version v4.4.13
      connecting to: mongodb://dbhost:27017/authSource=admin&compressors=disabled&gssapiServiceName=mongodb
      Error: username must contain a '.' separated database.user pair :
      connect@src/mongo/shell/mongo.js:374:17
      @(connect):2:6
      exception: connect failed
      exiting with code 1
      ```

      2, connect the db without auth, then auth by db.auth(), in this way, i can login into the db
      ```
      mongo --host dbhost -p 27017
      db.auth("user.name", "password") – the quote required
      user dbname
      show collections
      ```
      it show the collections.

            Assignee:
            Chris Kelly
            Reporter:
            Huang Teng
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: