[root@346439-eastore_db3 ~]# /db/mongodb-linux-x86_64-2.0.2/bin/mongo 127.0.0.1:37017
MongoDB shell version: 2.0.2
connecting to: 127.0.0.1:37017/test
> show dbs;
Tue May 7 06:41:53 uncaught exception: listDatabases failed:{ "errmsg" : "need to login", "ok" : 0 }
> exit
bye
[root@346439-eastore_db3 ~]#
[root@346439-eastore_db3 ~]#
[root@346439-eastore_db3 ~]#
[root@346439-eastore_db3 ~]#
[root@346439-eastore_db3 ~]#
[root@346439-eastore_db3 ~]# /db/mongodb-linux-x86_64-2.0.2/bin/mongo 127.0.0.1:37017 -uadmin -pxxxxx
MongoDB shell version: 2.0.2
connecting to: 127.0.0.1:37017/test
Tue May 7 06:42:53 uncaught exception: login failed
exception: login failed
PS:要去连接admin库才行:
[root@346439-eastore_db3 ~]# /db/mongodb-linux-x86_64-2.0.2/bin/mongo 127.0.0.1:37017/admin-uadmin -pxxxx
MongoDB shell version: 2.0.2
connecting to: 127.0.0.1:37017/admin
PRIMARY> rs.status();
"set" : "sso-rest",
"date" : ISODate("2013-05-07T06:43:21Z"),
"myState" : 1,
"members" : [
{
"_id" : 0,
"name" : "xxxxx:37017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"optime" : {
"t" : 1367909001000,
"i" : 37
},
"optimeDate" : ISODate("2013-05-07T06:43:21Z"),
"self" : true
},
{
"_id" : 1,
"name" : "xxxxx:37018",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 1113625,
"optime" : {
"t" : 1367909000000,
"i" : 10
},
"optimeDate" : ISODate("2013-05-07T06:43:20Z"),
"lastHeartbeat" : ISODate("2013-05-07T06:43:20Z"),
"pingMs" : 0
},
{
"_id" : 2,
"name" : "xxxxx:37017",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 268349,
"optime" : {
"t" : 1367908999000,
"i" : 32
},
"optimeDate" : ISODate("2013-05-07T06:43:19Z"),
"lastHeartbeat" : ISODate("2013-05-07T06:43:20Z"),
"pingMs" : 0
},
{
"_id" : 3,
"name" : "xxxxxx:37018",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 1113567,
"optime" : {
"t" : 1367908999000,
"i" : 19
},
"optimeDate" : ISODate("2013-05-07T06:43:19Z"),
"lastHeartbeat" : ISODate("2013-05-07T06:43:20Z"),
"pingMs" : 0
},
{
"_id" : 4,
"name" : "xxxxx:37019",
"health" : 1,
"state" : 7,
"stateStr" : "ARBITER",
"uptime" : 1113627,
"optime" : {
"t" : 0,
"i" : 0
},
"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
"lastHeartbeat" : ISODate("2013-05-07T06:43:21Z"),
"pingMs" : 0
}
],
"ok" : 1
}