mongodb数据库安装及管理工具mongo-express安装(docker方式)
环境:centos7
1、安装mongodb数据库
1 | docker run --name mongo -p 27017:27017 -v /mymongo/data:/data/db -d mongo |
2、新建数据库账号
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | [root@localhost ~]# docker exec -it mongo mongo admin MongoDB shell version v4.4.1 connecting to: mongodb: //127.0.0.1:27017/admin?compressors=disabled&gssapiServiceName=mongodb Implicit session: session { "id" : UUID( "419661b9-51be-47dc-b481-eef25e3c04ad" ) } MongoDB server version: 4.4.1 Welcome to the MongoDB shell. For interactive help, type "help" . For more comprehensive documentation, see https: //docs.mongodb.com/ Questions? Try the MongoDB Developer Community Forums https: //community.mongodb.com --- The server generated these startup warnings when booting: 2020-10-16T18:30:11.326+00:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted 2020-10-16T18:30:11.326+00:00: /sys/kernel/mm/transparent_hugepage/enabled is 'always' . We suggest setting it to 'never' 2020-10-16T18:30:11.326+00:00: /sys/kernel/mm/transparent_hugepage/defrag is 'always' . We suggest setting it to 'never' --- --- Enable MongoDB's free cloud-based monitoring service, which will then receive and display metrics about your deployment (disk utilization, CPU, operation statistics, etc). The monitoring data will be available on a MongoDB website with a unique URL accessible to you and anyone you share the URL with. MongoDB may use this information to make product improvements and to suggest MongoDB products and deployment options to you. To enable free monitoring, run the following command: db.enableFreeMonitoring() To permanently disable this reminder, run the following command: db.disableFreeMonitoring() --- #创建用户密码 > db.createUser({ user: 'admin' ,pwd: 'admin123' ,roles:[ { role: 'userAdminAnyDatabase' , db: 'admin' }, "readWriteAnyDatabase" ]}); Successfully added user: { "user" : "admin" , "roles" : [ { "role" : "userAdminAnyDatabase" , "db" : "admin" }, "readWriteAnyDatabase" ] } > # 尝试使用上面创建的用户信息进行连接。 > db.auth( 'admin' , 'admin123' ) 1 |
3、安装管理工具mongo-express
1 | docker run --link mongo:mongo -p 8081:8081 mongo-express |
4、页面查看管理工具http://ip:8081
做一个决定,并不难,难的是付诸行动,并且坚持到底。
分类:
mongodb
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)