'uncaught exception: SyntaxError: unexpected token: identifier :when trying to log into as an admin for mongo shell

I am following this tutorial

https://docs.nodebb.org/installing/os/windows/

I got thru most of it easily but when I go to login as an admin with this command:

mongo -u admin -p ojo --authenticationDatabase=admin

I get an error:

uncaught exception: SyntaxError: unexpected token: identifier :
@(shell):1:9

ojo is the password btw

the admin account was created and it shows up when you run show users

show users
{
        "_id" : "admin.admin",
        "userId" : UUID("e3c3df1d-f63d-48e3-ae65-b9cf03c86333"),
        "user" : "admin",
        "db" : "admin",
        "roles" : [
                {
                        "role" : "root",
                        "db" : "admin"
                }
        ],
        "mechanisms" : [
                "SCRAM-SHA-1",
                "SCRAM-SHA-256"
        ]
}
{
        "_id" : "admin.admin2",
        "userId" : UUID("0b87390b-2c08-4e21-9183-8a2406a9304e"),
        "user" : "admin2",
        "db" : "admin",
        "roles" : [
                {
                        "role" : "root",
                        "db" : "admin"
                }
        ],
        "mechanisms" : [
                "SCRAM-SHA-1",
                "SCRAM-SHA-256"
        ]
}

What am I doing incorrectly? Tried many attempts.



Solution 1:[1]

Don't open mongo shell and enter the connection string.

You have to enter the connection string (e.g., mongo mongodb+srv://m999student:[email protected]/testdb) from the operating system command prompt

  1. Press win + r
  2. Type cmd
  3. Paste the connection string
  4. now you'll be prompted to enter password, enter it and that's all!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Example person