Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

边看边学:初识MongoDB #35

Closed
imsobear opened this issue Dec 13, 2013 · 0 comments
Closed

边看边学:初识MongoDB #35

imsobear opened this issue Dec 13, 2013 · 0 comments
Labels

Comments

@imsobear
Copy link
Owner

对于数据库我并没有了解多少,之前接触过MySQL,但很多东西只是浅尝辄止,最多是了解一些SQL语句、关联表的设计、索引诸如此类的。近来一直想把后端的技术补上来,因此就从Mongo开始了,毫无疑问,我们都喜欢新的炫的东西,那么分布式、NoSQLJSON格式这些叠加起来的MongoDB刚好符合胃口,于是乎先选一本好书:《MongoDB 实战》,然后就可以步履蹒跚的上路了。

初识当然是要讲环境的搭建了,对于后台想关的技术,原则上使用Ubuntu会省去很多麻烦,但因为平时要照顾IE,又懒得再去搞双系统,所以就硬着头皮在Windows上搞了,过程倒也还好,没有想象中的那么艰辛,大体步骤如下:

  1. 下载MongoDB: 平时学习使用,下载32位和64位都无妨;
  2. 将下载好的zip解压到D:/下,大概是这个样子D:/mongodb
  3. 建立数据库目录:D:/mongodb/data
  4. 建立日志目录: D:/mongodb/logs/mongo.log
  5. 添加环境变量: 我的电脑-属性-高级-环境变量-系统变量中的path,加上D:/mongodb/bin
  6. 启动服务:在控制台中输入 mongod.exe --dbpath=D:\MongoDB\data,注:dbpath指的就是数据库的路径;
  7. 启动shell: 重开一个控制台输入mongo,然后就可以连上数据库做一些操作了;

这样使用起来比较麻烦,每次都需要开两个控制台,输入长长的命令,windows service可以解决这个问题:

在控制台中输入:
mongod.exe --dbpath=D:\mongodb\data --logpath=D:\mongodb\logs\mongo.log --install

这样以后在控制台中输入net start mongodb就可以启动服务了,然后输入mongo启动shell就可以操作了。如下图所示:

基本的安装过程就这么多,也没多少坑,运气好的话还是蛮顺利的。

MongoDB的优势的话,这方面的文章数不胜数,我个人理解最大的不同就是开发者不需要在schema上花费太多的精力,也不用因为要添加一个字段而消耗大量的沟通成本,另一方面,MongoDB本身就是为web量身定做,在分布式的支持上会比MySQL便利很多。

没有什么技术类的问题,纯属一些个人的记录。

@imsobear imsobear closed this as completed Apr 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant