Fully specified hostname required to run a script

26 views
Skip to first unread message

Glenn Sills

unread,
Oct 16, 2014, 8:25:54 AM10/16/14
to mongod...@googlegroups.com
I have written a very short Javascript file to do some updates on the server. The file looks like:

db = db.getSiblingDB('database');
db.MerchantInfo.update({merchantId:236066},{$set:{listingLogo:"foo.jpg"}});
db.MerchantInfo.update({merchantId:220420},{$set:{listingLogo:"bar.jpg"}});
db.MerchantInfo.update({merchantId:5908682},{$set:{listingLogo:"voobar.jpg"}});
db.MerchantInfo.update({merchantId:5284}, {$set:{listingLogo:"blaa.jpg"}});

I run command "Mongo hostname <script.js" and I get the following message for each update line:
 
not authorized on database to execute command { update: \"MerchantInfo\"

This seems weird to me because authentication is turned on yet and besides I can run each update in a shell just fine using no credentials. So I try the command ""Mongo hostname.mydomain.com <script.js" and the script runs just fine. What gives.

I am running a 2.6.4 Windows install against a 2.4 Linux server.


Asya Kamsky

unread,
Oct 19, 2014, 11:20:48 PM10/19/14
to mongodb-user
If you say

"mongo foobar" that does not take foobar as a hostname - it assumes
it's the database name.

If you want to specify hostname either use --host or specify mongo
hostname:port/dbname

Asya
> --
> You received this message because you are subscribed to the Google Groups
> "mongodb-user"
> group.
>
> For other MongoDB technical support options, see:
> http://www.mongodb.org/about/support/.
> ---
> You received this message because you are subscribed to the Google Groups
> "mongodb-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mongodb-user...@googlegroups.com.
> To post to this group, send email to mongod...@googlegroups.com.
> Visit this group at http://groups.google.com/group/mongodb-user.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mongodb-user/a412f677-c723-49ed-9f38-800651bf4e2d%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages