mongodb命令

mongoDB导出-导入数据

余生长醉 提交于 2019-11-27 05:54:24
--导出数据集 C:\MongoDB\db\bin>mongoexport -d ttx-xwms-test -c things -o d:\mongo_data\things.txt C:\MongoDB\db\bin> -- 安装路径 --备份数据库(导出整个数据库集) C:\MongoDB\db\bin>mongodump -h 127.0.0.1:27017 -d ttx-xwms-test -o d:\mongo_data\ C:\MongoDB\db\bin> -- 安装路径 --还原数据库(还原整个数据库集) C:\MongoDB\db\bin>mongorestore -h 127.0.0.1:27017 -d ttx-xwms-test_restore --dir d:\mongo_data\ttx-xwms-test\ C:\MongoDB\db\bin> -- 安装路径 -d 新的数据库名字 --dir d:\mongo_data\ttx-xwms-test\ 数据存在的目录名 在本地使用 27017 启动你的mongod服务。打开命令提示符窗口,进入MongoDB安装目录的bin目录输入命令mongodump: >mongodump执行以上命令后,客户端会连接到ip为 127.0.0.1 端口号为 27017 的MongoDB服务上,并备份所有数据到 bin

redis 入门之string(2)

放肆的年华 提交于 2019-11-27 04:58:39
set 用法 #set key value 设置value为字符串的键值对redis> SET key "value" #对不存在的key设置value OK redis> GET key "value" redis> SET key "new-value" # 对已经存在的key设置value OK redis> GET key "new-value" redis> SET key-with-expire-time "hello" EX 10086 #使用EX选项,设置过期时间,单位为秒OK redis> GET key-with-expire-time "hello" redis> TTL key-with-expire-time (integer) 10069 redis> SET key-with-pexpire-time "moto" PX 123321 #使用PX选项,设置时间为毫秒 OK redis> GET key-with-pexpire-time "moto" redis> PTTL key-with-pexpire-time (integer) 111939 redis> SET not-exists-key "value" NX #NX选项,只对不存在的key设置value OK # 键不存在,设置成功 redis> GET not-exists-key

mongoDB操作命令,摘自官方helper

自闭症网瘾萝莉.ら 提交于 2019-11-27 04:07:48
help show help show dbs show database names show collections show collections in current database show users show users in current database show profile show most recent system.profile entries with time >= 1ms use <db name> set curent database to <db name> db.addUser (username, password) db.removeUser(username) db.cloneDatabase(fromhost) db.copyDatabase(fromdb, todb, fromhost) db.createCollection(name, { size : ..., capped : ..., max : ... } ) db.getName() db.dropDatabase() // runs the collstats] command on each collection in the database db.printCollectionStats() db.currentOp() displays the

mongoDB操作命令及mongoDB的helper

喜欢而已 提交于 2019-11-27 04:07:08
此项目已开源,开源地址是: http ://mongodbhelper-csharp.googlecode.com/svn/trunk/ mongodb的helper using System; using System.Collections.Generic; using System.Linq; using System.Text; using MongoDB.Driver; using MongoDB.Bson; using MongoDB.Driver.Builders; namespace MongoDBHelper { /// <summary> /// mongodb的封装类。 /// add by yancong2008@gmail.com 2011.05.14 /// </summary> public sealed class MongoDBHelper //public sealed class MongoDBHelper<T> //where T :class { public static readonly string connectionString_Default = System.Configuration.ConfigurationManager.AppSettings["ConnectionString_mongoDB"]; public

初识python 之 MongoDB 基本操作

血红的双手。 提交于 2019-11-27 03:08:43
MongoDB与SQL对比: MongoDB 三元素:数据库、集合、文档 MongoDB 基本操作命令:   db 查看当前数据库   show dbs 查看所有数据库   use 数据库名 切换数据库,如果数据库不存在则创建(添加数据之后才会真正存在   db.dropDabase() 删除当前数据库   db.集合名.insert(要插入的数据) 添加数据到指定的集合中 db.user.insert({'id':1,'name':'lzh'}))   db.集合名.find() 从指定集合中查找数据 db.user.find() python操作MongoDB 需要导入pymongo包: import pymongo 获取连接mongodb的对象: client = pymongo.MongoClient('127.0.0.1',port=27017) 获取数据库,如果没有这个数据库,会自动创建,若未插入数据,不会真正创建: db = client.lzhdb 获取数据库的集合,及mysql数据库中的表: collection = db.user 写入数据:  插入一条数据: collection.insert({'id':1,'name':'lzh'}) # 等价于 collection.insert_one({'id':1,'name':'lzh'})  插入多条数据:

上手mongodb

牧云@^-^@ 提交于 2019-11-27 02:49:23
上手MongoDB MongoDB 是一个跨平台的,面向文档的数据库, 如果你了解spring-data-jpa的使用, 那么恭喜你,你已经可以使用mongodb做开发了 使用这种类型的数据库还是挺方便的,最小的存储单位是一个文档,但是文档有什么字段,有多少字段它都不关心,而mysql这样的典型的关系型数据库,开发之前得把表设计的明明白白的,说不定还得预留几个字段以备不时之需,因为后续再改就麻烦了 。它支持的数据结构非常松散,是类似 JSON 的 BSON 格式,因此可以存储比较复杂的数据类型。 体系结构 MongoDB Mysql database database collection 数据表 document 表中的一行记录 一个MongoDB实例支持多个database并存,同时一个database中可以包含多个collection,所以大家都说它是介于关系数据库和非关系数据库之间,因为它的组成结构真的特别像关系型数据库 支持的数据类型 数据类型名 BSON null {"XXX":null} 布尔值: {"XXX":true/false} int {"XXX":NumberInt("1")} Long {"XXX":NumberLong("1")} 字符串 {"XXX":"啊哈哈哈"} 日期 {"XXX":new Date()} 正则 {"XXX":null} 布尔值:

mongodb后台启动

吃可爱长大的小学妹 提交于 2019-11-27 02:35:37
以下实例中我们将data目录创建于根目录下(/)。 注意:/data/db 是 MongoDB 默认的启动的数据库路径(--dbpath)。 mkdir -p /data/db 注意:在使用 mongo 这个命令连接mongodb服务时,默认会去找根路径下的/data/db,作为数据库存放目录。 如果你的数据库目录不是/data/db,可以通过 mongo --dbpath <foldName> 来指定。 linux下mongodb启动后,关闭窗口,就自动停止了。这个时候需要用命令(数据库路径为根目录的情况下): mongod --fork --logpath /***/***/mongodb/mongo.log --logappend (如果没有该log文件则会自动创建) 数据库路径非根路径,则需指定: mongod --fork --dbpath /***/***/data/db --logpath /***/***/mongodb/mongo.log --logappend 来源: https://blog.csdn.net/qq_36742720/article/details/99292457

MongoDB常用数据库命令第三集

你离开我真会死。 提交于 2019-11-27 02:18:03
show dbs 查看已经存在的数据库 use 数据库名 切换到指定的数据库(无论数据库是否存在 均可切换成功) db 查看当前数据库 db.getCollectionNames() 查看当前数据库下一共有哪些集合 db.集合名.insert(文档) 向指定的集合录入一条文档 例如: db.users.insert({username:"xxx",age:98,height:180}) db.集合名.insert([文档1,文档2]) 向指定的集合插入多条文档 例如: db.users.insert([ {username:"黄晓明",age:35,height:180}, {username:"ab",age:18,height:149} ]) db.集合名.insertMany([文档1,文档2]) 插入多条数据 db.集合名.insertOne(文档) 插入单条数据 //==================== 查询 ==================== db.集合名.find() 查询指定的集合内所有数据 条件查询 db.集合名.find({条件},{显示字段}) 条件格式: 属性名:值 ====> 属性==值 属性名:{条件操作符:值} 其他条件查询 条件操作符 $gt : 大于 $gte : 大于等于 $lt : 小于 $lte : 小于等于 $in :

mongodb初探之安装与基础配置

自作多情 提交于 2019-11-27 01:39:57
./mongod --dbpath /home/goojia/power_mongodb_data --port 47017 --maxConns 1000 --fork --logpath /home/goojia/power_mongodb_data/mongodb.log --logappend ./mongod --dbpath /home/goojia/mongodb_data/ --maxConns 2000 --fork --logpath /home/goojia/mongodb_data/mongodb.log --logappend --rest 以下安装部分是在自己的32位centos5.6虚拟机上安装配置,不一定完全正确,仅供学习交流使用,相关部分请参考网上其他教程 1.下载安装mongodb [root@niutian365 soft]# wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-1.8.3.tgz [root@niutian365 soft]# tar zxvf mongodb-linux-i686-1.8.3.tgz [root@niutian365 soft]# mv mongodb-linux-i686-1.8.3 /data/mongodb [root@niutian365

MongoDB中的explain命令

核能气质少年 提交于 2019-11-27 01:32:24
执行命令显示结果 执行db.student_exam.find({student_age: 15}).explain(‘allPlansExecution’); { "queryPlanner" : { "plannerVersion" : 1.0, "namespace" : "myproject.student_exam", "indexFilterSet" : false, "parsedQuery" : { "student_age" : { "$eq" : 15.0 } }, "winningPlan" : { "stage" : "COLLSCAN", "filter" : { "student_age" : { "$eq" : 15.0 } }, "direction" : "forward" }, "rejectedPlans" : [ ] }, "executionStats" : { "executionSuccess" : true, "nReturned" : 633.0, "executionTimeMillis" : 5.0, "totalKeysExamined" : 0.0, "totalDocsExamined" : 10000.0, "executionStages" : { "stage" : "COLLSCAN", "filter" : {