MongoDB连接问题

时间:2015-10-21 19:02:36

标签: mongodb

MongoDB连接有什么问题吗?当我尝试连接到本地运行的MongoDB实例时出现以下错误:

QUERY    Error: 'createUser' command not found.  This is most likely because you are talking to an old (pre v2.6) MongoDB server

这是我启动MongoDB时的控制台行!

My-MacBook-Pro:Projects joe$ mongod --dbpath /Users/joe/Projects/my-data
Wed Oct 21 19:53:21 [initandlisten] MongoDB starting : pid=974 port=27017 dbpath=/Users/joe/Projects/my-data 64-bit host=My-MacBook-Pro.local
Wed Oct 21 19:53:21 [initandlisten] db version v2.0.6, pdfile version 4.5
Wed Oct 21 19:53:21 [initandlisten] git version: e1c0cbc25863f6356aa4e31375add7bb49fb05bc
Wed Oct 21 19:53:21 [initandlisten] build info: Darwin erh2.10gen.cc 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386 BOOST_LIB_VERSION=1_40
Wed Oct 21 19:53:21 [initandlisten] options: { dbpath: "/Users/joe/Projects/inland24-data" }
Wed Oct 21 19:53:21 [initandlisten] journal dir=/Users/joe/Projects/inland24-data/journal
Wed Oct 21 19:53:21 [initandlisten] recover : no journal files present, no recovery needed
Wed Oct 21 19:53:21 [websvr] admin web console waiting for connections on port 28017
Wed Oct 21 19:53:21 [initandlisten] waiting for connections on port 27017
Wed Oct 21 19:54:21 [clientcursormon] mem (MB) res:14 virt:2432 mapped:0
Wed Oct 21 19:57:27 [initandlisten] connection accepted from 127.0.0.1:50171 #1
Wed Oct 21 19:59:21 [clientcursormon] mem (MB) res:15 virt:2432 mapped:0

我不知道db版本在哪里是2.0.6,这很奇怪!我后来意识到这是我使用brew创建的一个旧的MongoDB实例。我设法摆脱它,现在我看到正在使用MongoDB 3.0.6!

所以,现在我遇到了第二个问题,即连接到数据库:

2015-10-21T20:55:25.664+0200 I ACCESS   [conn2] Failed to authenticate joe@mydb with mechanism MONGODB-CR: AuthenticationFailed UserNotFound Could not find user joe@mydb
2015-10-21T20:55:25.673+0200 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:52134 #11 (11 connections now open)