使用XAMPP和php 5.3 ext在Mac osx上安装Mongo db

嗨我(想)刚刚在我的本地xampp机器上安装了
MongoDB.

我在线跟踪教程,似乎都完成了:

>将预编译的mongo.so移动到XAMPP / xampfiles / lib / php / php5.3 / extensions / no-debug-non-zts-20090626 /
>在php.ini中添加了这行代码:

extension = mongo.so

>重启Apache
>连接到localhost,我可以在phpinfo()中看到mongo扩展名
>到http://localhost:27017看到mongo界面并且无法连接到它(Firefox返回错误)

然后我下载了用于mac osx的MongoHub客户端来创建/管理mongo数据库,但它说套接字错误,似乎没有与MongoDB的连接

我(想)我也安装了mongoDB本身

>我创建了一个目录:XAMPP / xampfiles / var / mongodb
>我在var / mongodbso下删除了tar MongoDB包文件,现在我有了var / mongodb / bin
>从var / mongodb我启动了这个命令:

./bin/mongod

它返回:

Sun Sep 11 22:40:32 [initandlisten] MongoDB starting : pid=946 port=27017 dbpath=/data/db/ 64-bit 
Sun Sep 11 22:40:32 [initandlisten] db version v1.8.3, pdfile version 4.5
Sun Sep 11 22:40:32 [initandlisten] git version: c206d77e94bc3b65c76681df5a6b605f68a2de05
Sun Sep 11 22:40:32 [initandlisten] build sys info: Darwin erh2.10gen.cc 9.6.0 Darwin Kernel Version 9.6.0: Mon Nov 24 17:37:00 PST 2008; root:xnu-1228.9.59~1/RELEASE_I386 i386 BOOST_LIB_VERSION=1_40
Sun Sep 11 22:40:32 [initandlisten] exception in initAndListen std::exception: dbpath (/data/db/) does not exist, terminating
Sun Sep 11 22:40:32 dbexit: 
Sun Sep 11 22:40:32 [initandlisten] shutdown: going to close listening sockets...
Sun Sep 11 22:40:32 [initandlisten] shutdown: going to flush diaglog...
Sun Sep 11 22:40:32 [initandlisten] shutdown: going to close sockets...
Sun Sep 11 22:40:32 [initandlisten] shutdown: waiting for fs preallocator...
Sun Sep 11 22:40:32 [initandlisten] shutdown: closing all files...
Sun Sep 11 22:40:32 closeAllFiles() finished
Sun Sep 11 22:40:32 dbexit: really exiting now

启动./bin/mongo也会返回:

MongoDB shell version: 1.8.3
connecting to: test
Sun Sep 11 22:41:11 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:79
exception: connect failed

最佳答案 你必须用这个命令启动mongo

mongod --dbpath=data

–dbpath = data参数是数据库的分配位置,数据是路径,可以是/ var / lib / mongodb / data或/ data / mongodb.

在那个命令之后你可以去http://localhost:27017并看到mongodb监视器.

祝好运!

点赞