Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6553881
  • 博文数量: 1005
  • 博客积分: 8199
  • 博客等级: 中将
  • 技术积分: 13071
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-25 20:19
个人简介

脚踏实地、勇往直前!

文章分类

全部博文(1005)

文章存档

2020年(2)

2019年(93)

2018年(208)

2017年(81)

2016年(49)

2015年(50)

2014年(170)

2013年(52)

2012年(177)

2011年(93)

2010年(30)

分类: Mysql/postgreSQL

2012-12-06 19:59:11

环境:
OS: Windows 2003
DB:2.0.8
 
1.下载mongodb
下载地址为
,根据OS选择安装的版本.
我这里下载的是mongodb-win32-i386-2.0.8.zip
 
2.解压缩mongodb-win32-i386-2.0.8.zip
解压缩该zip包,我这里解压缩到E:\mongodb,同时在该目录下创建db和log两个文件夹,这样的话该目录有如下三个文件夹.



在log文件夹下创建日志文件mongodb.log,完全目录为E:\mongodb\log
 
3.在PATH变量中加入E:\mongodb\bin,这样就可以直接调用bin目录下的exe文件.
 
4.执行如下命令
mongod -dbpath "E:\mongodb\db"
执行此命令即将mongodb的数据库文件创建到E:\mongodb\db目录

 
5.运行mongo.exe
C:\Documents and Settings\xueliang.huang>mongo
MongoDB shell version: 2.0.8
connecting to: test
> help
        db.help()                    help on db methods
        db.mycoll.help()             help on collection methods
        rs.help()                    help on replica set methods
        help admin                   administrative help
        help connect                 connecting to a db help
        help keys                    key shortcuts
        help misc                    misc things to know
        help mr                      mapreduce
        show dbs                     show database names
        show collections             show collections in current database
        show users                   show users in current database
        show profile                 show most recent system.profile entries with time >= 1ms
        show logs                    show the accessible logger names
        show log [name]              prints out the last segment of log in memory, 'global' is default
        use                 set current database
        db.foo.find()                list objects in collection foo
        db.foo.find( { a : 1 } )     list objects in foo where a == 1
        it                           result of the last line evaluated; use to further iterate
        DBQuery.shellBatchSize = x   set default number of items to display on shell
        exit                         quit the mongo shell
当mongod.exe被关闭时,mongo.exe 就无法连接到数据库了,因此每次想使用mongodb数据库都要开启mongod.exe程序,所以比较麻烦,接下来我们将接下来我们将
MongoDB安装为windows服务吧
 
6.MongoDB安装为windows服务
创建服务
mongod --dbpath "E:\mongodb\db" --logpath "E:\mongodb\log\mongodb.log" --install --serviceName "mongodb"
 net start mongodb(开启服务)
net stop mongodb(关闭服务)
删除服务
mongod --dbpath "E:\mongodb\db" --logpath "E:\mongodb\log\mongodb.log" --remove --serviceName "mongodb"

要是出现如下错误的话需要将db目录下的mongod.lock删除后再启动
>mongo
>couldn't connect to server 127.0.0.1 shell/mongo.js:84

-- The End --

阅读(8778) | 评论(0) | 转发(0) |
0

上一篇:mysql日常管理

下一篇:mysql备份和恢复

给主人留下些什么吧!~~