问题
Trying to access MongoHQ directly:
> mongo mongodb://heroku:mypassword@alex.mongohq.com:10046/myapp
MongoDB shell version: 2.4.3
connecting to: mongodb://heroku:mypassword@alex.mongohq.com:10046/myapp
Tue Jun 4 16:10:09.255 Assertion failure _setName.size() src/mongo/client/dbclientinterface.h 211
0x10017116b 0x100135396 0x100068356 0x100129bab 0x10010f92f 0x10024b2fa 0x139ba3a06362 0x139ba3a0ce93 0x139ba3a400c9 0x139ba3a0c76e
0 mongo 0x000000010017116b _ZN5mongo15printStackTraceERSo + 43
1 mongo 0x0000000100135396 _ZN5mongo12verifyFailedEPKcS1_j + 310
2 mongo 0x0000000100068356 _ZN5mongo16ConnectionString5parseERKSsRSs + 1878
3 mongo 0x0000000100129bab _ZN5mongo17mongoConsExternalEPNS_7V8ScopeERKN2v89ArgumentsE + 187
4 mongo 0x000000010010f92f _ZN5mongo7V8Scope10v8CallbackERKN2v89ArgumentsE + 175
5 mongo 0x000000010024b2fa _ZN2v88internalL30Builtin_HandleApiCallConstructENS0_12_GLOBAL__N_116BuiltinArgumentsILNS0_21BuiltinExtraArgumentsE1EEEPNS0_7IsolateE + 618
6 ??? 0x0000139ba3a06362 0x0 + 21559186056034
7 ??? 0x0000139ba3a0ce93 0x0 + 21559186083475
8 ??? 0x0000139ba3a400c9 0x0 + 21559186292937
9 ??? 0x0000139ba3a0c76e 0x0 + 21559186081646
Tue Jun 4 16:10:09.264 JavaScript execution failed: Error: assertion src/mongo/client/dbclientinterface.h:211 at src/mongo/shell/mongo.js:L114
exception: connect failed
What's to be done?
回答1:
This is a shell bug and it's not a new one. Basically the mongo shell doesn't accept the same format of connection string that regular mongodb drivers do. I can reproduce this error in the current and previous versions and this syntax isn't expected to work (though it probably shouldn't crash either, but there is already a bug for the shell to accept standard connection string: jira.mongodb.org/browse/SERVER-3254
Meanwhile you can connect by using the mongo shell options such as
mongo -u <user> -p <passwd> hostIP:port/db
or
mongo --host host --port port [ other options ] db
回答2:
Just see if you have $ in your password, in that scenario enclose your password with ' ' then try to connect.
e.g.
mongo mongodb://host:port/authdb -username dbusername -p 'password$123'
来源:https://stackoverflow.com/questions/16929040/javascript-execution-failed-connected-to-mongohq-shell