Using SCRAM-SHA-1

You can configure the connector to use the SCRAM-SHA-1 protocol to authenticate the connection. SCRAM-SHA-1 is the default authentication protocol used by MongoDB.

You provide the configuration information to the connector in the connection URL. For more information about the syntax of the connection URL, see Building the Connection URL.

To configure SCRAM-SHA-1 authentication:

  1. Connect to the server using a connection URL written in the following format:
  2. jdbc:mongodb://[UserName]:[Password]@[Host]:[Port]/[Database]?AuthMechanism=SCRAM-SHA-1

    The variables are defined as follows:

    • [UserName] is your MongoDB user name.
    • [Password] is the password corresponding to your MongoDB user name.
    • [Host] is the DNS or IP address of the server.
    • [Port] is the number of the TCP port to connect to. Specifying the port number is optional if you are connecting to port 27017.
    • [Database] is the name of the database.
    Important:

    Important:

    If the user name or password contains reserved characters, those characters must be encoded using URL encoding (percent encoding). For example, the user name ch@ng would be encoded in the connection URL as ch%40ng.

    For example:

    jdbc:mongodb://jsmith:pass12345@192.168.1.1:47017/
    TeamRoster?AuthMechanism=SCRAM-SHA-1

  3. Optionally, to use a database other than the admin database to check your credentials, set the AuthSource property to the name of the database. For example:
  4. jdbc:mongodb://jsmith:pass12345@192.168.1.1:47017/
    TeamRoster?AuthMechanism=SCRAM-SHA-1
    &AuthSource=MongoDB01