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

发布于 2024-12-04 04:53:55 字数 2300 浏览 1 评论 0原文

您好,我(认为)刚刚将 MongoDB 安装到我的本地 xampp 计算机上。

我按照在线教程进行操作,似乎一切都已完成:

  1. 将预编译的mongo.so移动到XAMPP/xampfiles/lib/php/php5.3/extensions/no-debug- non-zts-20090626/

  2. 将此行代码添加到 php.ini 中:

    <块引用>

    扩展名=mongo.so

  3. 重新启动 Apache

  4. 我可以看到 mongo 扩展
  5. 转到 http://localhost:27017查看 mongo 接口,但无法连接到它(Firefox 返回错误)

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

我(认为)我还安装了 mongoDB 本身

  1. 我创建了一个目录:XAMPP/xampfiles/var/mongodb
  2. 我在 var/mongodb 下提取了 tar MongoDB 包文件,所以现在我有 var/mongodb/bin
  3. 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:

  1. Moved pre-compiled mongo.so into XAMPP/xampfiles/lib/php/php5.3/extensions/no-debug-non-zts-20090626/

  2. Added this line of code into php.ini:

    extension = mongo.so

  3. Restarted Apache

  4. Connected to localhost and I can see the mongo extension in phpinfo()

  5. 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

  1. I created a directory: XAMPP/xampfiles/var/mongodb
  2. I excracted tar MongoDB package file under var/mongodbso now I have var/mongodb/bin
  3. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

欢烬 2024-12-11 04:53:55

您必须使用此命令启动 mongo

mongod --dbpath=data

--dbpath=data 参数是分配数据库的位置,data 是路径,可能类似于 /var/lib/mongodb/data 或 /data/mongodb。

在该命令之后,您可以转到 http://localhost:27017 并查看 mongodb 监视器。

祝你好运!

You have to start mongo with this command

mongod --dbpath=data

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文