MongoDB3.6安装

1. 下载
  
2. 安装
    点击msi文件,选择安装,如下图所示,
       
     next
     
    选择同意,继续next 

    选择complate,默认安装;custom,自定义安装,可以选择安装路径,安装内容

    选择是否安装 mongoDb compass(可视化客户端),这个是在线安装,速度太慢,容易报错,可以暂时不选择,后面独立安装,继续next

     选择install,安装,
3. 运行
     在安装目录下,创建data、logs 文件夹,并创建 mongo.log,mongo.conf文件,内容如图


        其中mongo.conf  文件内容
dbpath=C:\MongoDB\Server\3.6\data #数据库路径  
logpath=C:\MongoDB\Server\3.6\logs\mongo.log #日志输出文件路径  
logappend=true #错误日志采用追加模式  
journal=true #启用日志文件,默认启用  
quiet=true #这个选项可以过滤掉一些无用的日志信息,若需要调试使用请设置为false  
port=27017 #端口号 默认为27017  
   
然后进入cmd下,进入  C:\MongoDB\Server\3.6\bin,输入
    mongod -config "C:\MongoDB\Server\3.6\mongo.conf"
   
  

然后再打开一个cmd命令, 进入   C:\MongoDB\Server\3.6\bin,输入
    mongo 127.0.0.1:27017
    进入mongo命令,输入  show dbs,
> show dbs
admin   0.000GB
config  0.000GB
local   0.000GB
  mongodb  安装成功


注:  
           运行时,日志出现警告  Access control is not enabled for the database.
2018-04-05T21:31:56.080+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-04-05T21:31:56.080+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2018-04-05T21:31:56.080+0800 I CONTROL  [initandlisten] 
2018-04-05T21:31:56.080+0800 I CONTROL  [initandlisten] ** WARNING: This server is bound to localhost.
2018-04-05T21:31:56.080+0800 I CONTROL  [initandlisten] **          Remote systems will be unable to connect to this server. 
2018-04-05T21:31:56.080+0800 I CONTROL  [initandlisten] **          Start the server with --bind_ip <address> to specify which IP 
2018-04-05T21:31:56.080+0800 I CONTROL  [initandlisten] **          addresses it should serve responses from, or with --bind_ip_all to
2018-04-05T21:31:56.080+0800 I CONTROL  [initandlisten] **          bind to all interfaces. If this behavior is desired, start the
2018-04-05T21:31:56.080+0800 I CONTROL  [initandlisten] **          server with --bind_ip 127.0.0.1 to disable this warning.
   
> show dbs
admin   0.000GB
config  0.000GB
local   0.000GB
> use admin
switched to db admin
> db.createUser(
...   {
...     user: "admin", //用户名
...     pwd: "passwd", //密码
...     roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] //设置权限
...   }
... )
Successfully added user: {
        "user" : "admin",
        "roles" : [
                {
                        "role" : "userAdminAnyDatabase",
                        "db" : "admin"
                }
        ]
}
> commit;

如上,重启数据库,OK
  



  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值