Enable Authentication

To enable the authentication, perform the following steps:

  1. Go to the server where MongoDB service has been installed. Open the Command Prompt as Administrator and execute the command below.
    mongodb
  2. Execute the command below:
    MongoDB> use admin
  3. Make the following changes in the values before execution:
    • user:<username>
    • pwd :<password>

    Use a strong, complex password that follows enterprise security standards. The password should:

    • Contains at least 12-16 characters
    • Include a mix of lowercase and uppercase letters
    • Include numbers and special characters
    • Avoid dictionary words, personal information and predictable patterns.
      Note:

      For password rotation customer rotation policy will be adhered by GenAI operations resources.

    Run the below command
    db.createUser(
    {
    user: "<username>",
    pwd: "<password>",
    roles: [
    { role: "userAdminAnyDatabase", db: "admin" },
    { role: "root", db: "admin" },
    "readWriteAnyDatabase"
    ]
    }
    )

    On successful execution, You will get {ok: 1} message.

  4. Make the following changes in mongod.cfg. Refer the below screenshot:
  5. Restart the MongoDB service on the server.
  6. Re-open the Command Prompt as Administrator and open the MongoDB terminal using the following command:
    mongosh --host <IP> --port <Port> -u <username> -p <password> --authenticationDatabase
     "admin"
    For e.g. - mongosh --host x.x.xx.x --port 27017 -u <username> -p <password> --authenticationDatabase "admin"
    Note:
    Ensure that the IP address is the actual MongoDB server IP reachable from GENAI Application running on Kubernetes cluster.