2

I'm trying to connect to a MongoDB database that requires a password while also loading and running a script file on the database. I want to do it all from the command line and have the mongo shell exit afterwards. My problem is that I cannot do both at the same time, e.g.

$ mongo example.com:10023/database -u username -p script.js

The above command will think that script.js is actually my password, which it of cause isn't. I want it to actually prompt me for my password after I enter the command.

How can I do that?

1 Answer 1

4

Try moving the arguments around so that script.js does not follow your password parameter.

$mongo example.com:10023/database script.js -u username -p

Sign up to request clarification or add additional context in comments.

1 Comment

So freaking simple. And yet I never thought about moving the arguments around. Why? Because "<file.js> .. Must be the last option specified.". Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.