使用 XAMPP 和 php 5.3 ext 在 Mac osx 上安装 Mongo db
您好,我(认为)刚刚将 MongoDB 安装到我的本地 xampp 计算机上。
我按照在线教程进行操作,似乎一切都已完成:
将预编译的
mongo.so
移动到XAMPP/xampfiles/lib/php/php5.3/extensions/no-debug- non-zts-20090626/
将此行代码添加到 php.ini 中:
<块引用>扩展名=mongo.so
重新启动 Apache
- 我可以看到 mongo 扩展
转到 http://localhost:27017查看 mongo 接口,但无法连接到它(Firefox 返回错误)
然后我下载了 MongoHub Mac 客户端osx 创建/管理 mongo 数据库,但它说套接字错误,并且似乎没有与 MongoDB 的连接
我(认为)我还安装了 mongoDB 本身
- 我创建了一个目录:
XAMPP/xampfiles/var/mongodb
- 我在
var/mongodb
下提取了 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
Hi I (think) just installed MongoDB to my local xampp machine.
I followed tutorials online and all seems to be done:
Moved pre-compiled
mongo.so
intoXAMPP/xampfiles/lib/php/php5.3/extensions/no-debug-non-zts-20090626/
Added this line of code into php.ini:
extension = mongo.so
Restarted Apache
Connected to localhost and I can see the mongo extension in
phpinfo()
Went to http://localhost:27017 to see mongo interface and couldn't connect to it (Firefox returns an error)
Then I downloaded the MongoHub client for mac osx to create/manage mongo databases, but it says socket error, and seems there is no connection to MongoDB
I (think) I installed also mongoDB itself
- I created a directory:
XAMPP/xampfiles/var/mongodb
- I excracted tar MongoDB package file under
var/mongodb
so now I havevar/mongodb/bin
- From
var/mongodb
I launched this command:
./bin/mongod
And it returned:
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
Launching ./bin/mongo
also returns:
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须使用此命令启动 mongo
--dbpath=data 参数是分配数据库的位置,data 是路径,可能类似于 /var/lib/mongodb/data 或 /data/mongodb。
在该命令之后,您可以转到 http://localhost:27017 并查看 mongodb 监视器。
祝你好运!
You have to start mongo with this command
The --dbpath=data argument is where your database will be allocated, data is the path and could be something like /var/lib/mongodb/data or /data/mongodb.
And after that command you can go to http://localhost:27017 and see the mongodb monitor.
Good luck!