MongoDB

Windows

由于工作环境限制,只测试了Windows环境,Linux 除了安装稍微麻烦一点 其他操作都一样

下载

国内下载地址
http://dl.mongodb.org/dl/win32/x86_64
百度云盘下载
链接:https://pan.baidu.com/s/1QSst0VNhN_VctlW37-72Xg 
提取码:btxe

安装

无脑一键安装

启动

进入MongoDB安装目录下

Server\3.4\bin

运行

mongod --dbpath=D:\MongoDB_data
// D:\MongoDB_data 为数据库存放位置

安全模式(需要用户密码登录)启动

mongod --auth --dbpath=D:\MongoDB_data

命令行 创建用户(可选)

// 进入MongoDB命令行
mongo
// 使用admin库
use admin
// 创建超级管理员 相当于MySQL的root
// 先创建一个超级管理员
db.createUser({
    user:"lane",
    pwd:"lane8289",
    roles: [{
        role:"root",
        db:"admin"
    }]
})
// 创建一个 可读写制定数据库的 用户
db.createUser({
    user:"apidata",
    pwd:"apidata",
    roles: [{
        role:"readWrite",
        db:"apidata"
    }]
})
// 查看已存在的用户
db.system.users.find()
// 删除一个用户
usedbname(adminorotherdbname)
db.system.users.remove({
    user:"free-cms"
})
db.system.users.find()

// read:允许用户读取指定数据库
// readWrite:允许用户读写指定数据库
// dbAdmin:允许用户在指定数据库中执行管理函数,如索引创建、删除,查看统计或访问// // // // system.profile
// userAdmin:允许用户向system.users集合写入,可以找指定数据库里创建、删除和管理用户
// clusterAdmin:只在admin数据库中可用,赋予用户所有分片和复制集相关函数的管理权限。
// readAnyDatabase:只在admin数据库中可用,赋予用户所有数据库的读权限
// readWriteAnyDatabase:只在admin数据库中可用,赋予用户所有数据库的读写权限
// userAdminAnyDatabase:只在admin数据库中可用,赋予用户所有数据库的userAdmin权限
// dbAdminAnyDatabase:只在admin数据库中可用,赋予用户所有数据库的dbAdmin权限。
// root:只在admin数据库中可用。超级账号,超级权限

登录时先 进入admin库 否则各种报错

Comments

  1. Man kann jeden Tag etwas Neues hier lernen. Ich bin ein regelmäßiger für die meisten von denen Blogs, aber immer noch nicht um ein Paar von ihnen wissen.

  2. naturally like your web site but you have to take a look at the spelling
    on several of your posts. Many of them are rife with spelling problems and I in finding it very bothersome to inform the
    reality then again I will surely come back again.

  3. I blog often and I genuinely appreciate your information. Your article has really peaked my interest.
    I will book mark your blog and keep checking for new information about once a week.
    I opted in for your RSS feed as well.

  4. Undeniably believe that which you stated. Your favorite reason seemed to be on the internet the easiest factor
    to remember of. I say to you, I certainly get annoyed at the same time
    as people consider concerns that they just do not understand about.
    You controlled to hit the nail upon the highest and also defined out
    the entire thing with no need side-effects , people
    can take a signal. Will probably be again to get more.
    Thank you

  5. I’ve been surfing online more than 3 hours these days, but I never
    discovered any interesting article like yours.
    It is lovely price sufficient for me. In my view, if all website owners and bloggers made excellent content material as you did,
    the web can be a lot more helpful than ever before.

  6. I’m curious to find out what blog platform you’re utilizing?
    I’m experiencing some minor security issues with my latest site and I’d like
    to find something more safe. Do you have any suggestions?

  7. I like the helpful information you provide in your articles.
    I’ll bookmark your weblog and check again here regularly.
    I’m quite certain I will learn many new stuff right here!
    Good luck for the next!

  8. If some one wants expert view on the topic of blogging and
    site-building afterward i suggest him/her to go to see this webpage, Keep up the pleasant job.

  9. Good day! I could have sworn I’ve been to your blog before but after looking
    at many of the articles I realized it’s new to me.

    Regardless, I’m definitely happy I discovered it and I’ll be bookmarking
    it and checking back regularly!

  10. Howdy! I’m at work browsing your blog from my new iphone 3gs!
    Just wanted to say I love reading through your blog and look forward to
    all your posts! Carry on the superb work!

发表评论

电子邮件地址不会被公开。