Difference between -u and - -username, -p and - -password

Quick question
Why do we use -u in the first command and --username in the second one.
Are they the same or different?
Same thing for -p and --password.

mongo admin -u root -p root123

mongo --host  --username root --password root --authenticationDatabase admin

Hi @Alpha_Ly

Short answer: It is the same.

Longer answer

If you run mongo -h or mongo --help it will tell you the meaning.

For example mongo --help //or -h outputs:

  -u [ --username ] arg       username for auth
  -p [ --password ] arg       password for auth

Normally, double dash options like --collection can be condensed -c unless there is another, more useful shorthand.

1 Like

Ok thank you.