User creation problem

I get an error when I try to create a user in mongo shell after connecting to the port 27000. I already enabled authentication in mongod.

May be the user already created/exists?
Please authenticate the user by db.auth

Like @Ramachandra_37567 suggested!
And I believe that you’re doing the Launching Mongod lab which means that you already ran this command:
This command creates the user and you can create the first user once using the localhost exception. After this point, if you have authentication enabled, you must always provide login credentials each time you fire up mongo.

Authentication can be done in one of two ways:

  • Launch mongo with the credentials:
    mongo --host <host> --port 123 -u <username> -p <password> --authenticationDatabase admin
    mongo --host <host> --port 123 --username <username> --password <password> --authenticationDatabase admin
    mongo admin --host <host> --port 123 -u <username> -p <password>
    mongo --host <host> --port 123 -u <username> -p <password>
    By default, it authenticates against the admin db if you don’t specify the authenticationDatabase option.
  • Launch mongo without credentials, switch to the admin db and authenticate with the credentials:
    mongo --host <host> --port 123
    use admin
    db.auth("<username>", "<password>")
    This is the method @Ramachandra_37567 is referring to.

I used this command “mongo --host --port 123 -u -p --authenticationDatabase admin”. Thanks sir it works.