I need to create a MongoDB database and user, but everything via shell.
I found something about --eval and --shell, but I could not get it to work, I'm trying this way:
mongo mongodb://11.11.123.321:27017 --eval "db.createUser({user: "teste", pwd: "teste123", roles: [{role: "readWrite", db: "novaBase"}]})"
Of course, if I run the initial command give an enter and then run the second one will work, but the current scenario I need to do all this "all at once" with an ssh lib that connects to the server and runs the command, I do this with mysql already example:
mysql -u root -pteste123 -e "CREATE USER teste@localhost"........