- https://docs.mongodb.com/master/tutorial/install-mongodb-on-amazon/ 使用yum 安装
修改部分配置文件
123456789101112131415161718192021222324252627282930313233343536373839404142434445461. sudo vi /etc/mongod.conf 编辑配置文件 如下2. # mongod.conf3.4. # for documentation of all options, see:5. # http://docs.mongodb.org/manual/reference/configuration-options/6.7. # where to write logging data.8. systemLog:9. destination: file10. logAppend: true11. path: /var/log/mongod.log12.13. # Where and how to store data.14. storage:15. dbPath: /data/db16. journal:17. enabled: true18. # engine:19. # mmapv1:20. # wiredTiger:21.22. # how the process runs23. processManagement:24. fork: true # fork and run in background25. pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile26.27. # network interfaces28. net:29. port: 2701730. bindIp: 127.0.0.1 # Listen to local interface only, comment to listen on all interfaces.31.32.33. security:34. authorization: enabled (关键部分 删除中文)35.36. #operationProfiling:37.38. #replication:39.40. #sharding:41.42. ## Enterprise-Only Options43.44. #auditLog:45.46. #snmp:按照 https://docs.mongodb.com/manual/tutorial/enable-authentication/ 该网址中的内容使用 db.createUser() 创建一个用户
中文翻译 http://www.cnblogs.com/qingtianyu2015/p/6148127.html
备注:增删要增加readWrite 属性
重启数据库 ok
- 进入数据时要先 12use admindb.auth("myUserAdmin", "abc123" )