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.
Thanks

mongo admin -u root -p root123

mongo --host 127.0.0.1:27017  --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.