[Mongodb]3.2版本的一些基本操作--待续
一、缘由
今天公司测试股票交易系统,需要拉取大量的数据存放,故考虑放在mongodb里。
二、一些基本操作
1、权限管理
mongo默认是不用账号就能登陆的,默认端口27017,但是这不太安全。我们要启用认证登陆。
1)开启安全认证:修改mongo.conf里,security.authorization=enbaled
2)创建管理员用户和普通用户
创建管理员用户:
use admin
db.createUser(
{
user: "myUserAdmin",
pwd: "abc123",
roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
}
)
创建普通用户:
use admin
db.createUser(
{
user: "myTester",
pwd: "xyz123",
roles: [ { role: "readWrite", db: "test" },
{ role: "read", db: "reporting" } ]
}
)
注意:上述账号认证数据库(authenticationDatabase)都为admin库(也可以为其他库)。
3)重启mongodb,用mongo shell 认证方式登陆
mongo --port 27017 -u "myUserAdmin" -p "abc123" --authenticationDatabase "admin"
或者 登陆后,进行用户授权:
$mongo $use test
$db.auth("myTester", "xyz123" )
注:mongodb 3.2官方文档:关于管理账号认证,点这里;关于配置文件详情,点这里。
4)其他账户操作:
前提是 use db;
查询用户权限:db.system.users.find();
查询用户权限2:use reporting(需有reporting库的读权限)
db.getUser("reportsUser")
删除用户:db.dropUser("user_name");
删除用户(root):db.system.users.remove({user:'user_name'});
更改用户密码:db.changeUserPassword("user_name","password");
2、CURD操作
[Mongodb]3.2版本的一些基本操作--待续的更多相关文章
- MongoDB 3.6版本关于bind_ip设置
2017年下半年新发布的MongoDB 3.6版本在安全性上做了很大提升,主要归结为两点: 1.将将bind_ip 默认值修改为了localhost: 2. 在db.createUser()和 db. ...
- scons编译mongodb(vs2008版本)遇到的问题总结
OS:win7 64 boost:1.49 mongodb:2.4.6(推荐64位版本,当然如果你系统是32位的,只能使用32的版本了) IDE:vs2008(2010的同学请跳过吧,因为官网提供的就 ...
- spring集成mongodb jar包版本问题
在开发过程中,spring集成mongodb的jar包. 如果需要使用排序功能. spring-data-mongodb-1.4.1.RELEASE.jar 的版本为1.4.1,如果使用如下代码: Q ...
- Springboot整合MongoDB(Eclipse版本)
IDEA版本其实也差不多的,大同小异 简单Demo地址: https://blog.csdn.net/shirukai/article/details/82152243 Springboot项目整合M ...
- linux下安装mongodb(php版本5.3)
转:原文出处忘记了. 1. 下载MongoDB 2. 解压文件到某目录下,然后重命名: [root@localhost var]# tar -xzvf mongodb-linux-i686-2.0.1 ...
- mongodb 3.0 版本分片部署步骤
# linux 网络优化 1. 文件中/etc/sysctl.conf, 加入 net.core.somaxconn = 2048 fs.file-max = 2000000 fs.nr_open = ...
- mongodb 性能提高之利用索引, 待续
> 10 , 用户无法忍受 >1s , 需要加装中提示 数据库对软件整体影响是不言而喻的, 那么使用 MOngoDB时 该如何提高数据库性能 第一: 索引, 相当于记忆法的 地点桩 1. ...
- MongoDB 3.4版本, C# 驱动 2.4 操作
private static string _connStr = "mongodb://127.0.0.1:27017"; private static string _dbNam ...
- WebFlux04 SpringBootWebFlux集成MongoDB之Windows版本、WebFlux实现CRUD、WebFlux实现JPA、参数校验
1 下载并安装MongoDB 1.1 MongoDB官网 1.2 下载 solutions -> download center 1.3 安装 双击进入安装即可 1.3.1 安装时常见bug01 ...
随机推荐
- 读javascript高级程序设计04-canvas
一.基本用法 1.要使用canvas元素,需要先给定其width和height来设置绘图区域的大小.canvas中间的文本会在浏览器不支持canvas的情况下显示出来. <canvas widt ...
- Windows Store App 插值动画
插值动画支持DoubleAnimation.ColorAnimation和PointAnimation类型的动画.其中比较常用的是DoubleAnimation动画,它可以用来控制界面元素的Doubl ...
- 给一个div绝对定位后,如何让它水平居中
<style> .footer{position:absolute;left:0;right:0} </style> <div classs="footer&q ...
- wdcp 打开网页显示 Apache 2 Test Page powered by CentOS
是因为更新过系统,安装并更新了系统自带的apache 执行这个命令即可 #ln -sf /www/wdlinux/init.d/httpd /etc/rc.d/init.d/httpd#reboot
- leetcode N-Queens/N-Queens II, backtracking, hdu 2553 count N-Queens, dfs 分类: leetcode hdoj 2015-07-09 02:07 102人阅读 评论(0) 收藏
for the backtracking part, thanks to the video of stanford cs106b lecture 10 by Julie Zelenski for t ...
- 解决 iOS7 通过tag 找不到 UITableViewCell 的子控件
当iOS7问世,程序的世界就混乱了,以前良好的程序,现在是一塌糊涂,于是只能把问题一个一个攻破. 由于项目当中需要每个cell显示数目不同的图片,于是我在每个cell 赋值之前,通过一下方法把cell ...
- iOS webView 远程html加载本地资源
昨天,一个朋友让我帮他在IOS上弄这样一件事情: webView 调用远程URL,并且让远程的web 通过自定义标签能实现内嵌本地的图片.js 或音频等. 比如:在服务器端 的html文件中 这样写到 ...
- understanding Nhibernate Hilo
http://stackoverflow.com/questions/2738671/please-explain-nhibernate-hilo http://stackoverflow.com/q ...
- Libgdx 开发指南(1.1) 应用框架——生命周期
生命周期 Libgdx应用有一个定义好的生命周期,控制着整个应用的状态,例如creation, pausing, resuming, disposing ApplicationListener 开发者 ...
- C++ Daily 《4》----一个简单的 int to string 的方法
经常会在项目中用到 int to string, 之前一般用C语言的 sprintf, 发现C++ 中的 ostringstream 可以轻松完成这个任务. #include <iostream ...