做网站的地方,wordpress点击分类目录空白,网站建设富库,百度搜不到我的网站一.首先去官网下载对应的的mongodb ,本人的操作系统是win7 64位 mongodb-win32-x86_64-2.0.6.rar 解压安装#xff1a;进入到bin目录下#xff0c;会看到N多的.exe文件 二.启动mongodb mongod.exe --dbpathd:\mongo\data\db --logpathd:\mongo\log\log.txt, 通过浏览器访问…一.首先去官网下载对应的的mongodb ,本人的操作系统是win7 64位 mongodb-win32-x86_64-2.0.6.rar 解压安装进入到bin目录下会看到N多的.exe文件 二.启动mongodb mongod.exe --dbpathd:\mongo\data\db --logpathd:\mongo\log\log.txt, 通过浏览器访问localhost:27017;如果显示 You are trying to access MongoDB on the native driver port. For http diagnostic access, add 1000 to the port number 就将端口改成28017表示mongodb服务端已经成功开启 三.重新打开cmd进入到bin目录下点击mongo 即进入了客户端开始你的命令吧 四.mongo命令操作 1. help 和 db.help(),通过help命令和db.help()来查看mongo的各种命令。 2.库的操作 show dbs //显示所有的数据库use database_name //切换数据库和使用数据库db.dropDatabase() //删除数据库db.repaireDatabase() //修复当前数据库db.getName() //获取数据库名称db.stats() //获取数据库信息db.version() //数据库版本db.getMongo() //当前db链接服务器地址3.数据表操作 show collections //查看当前库的所有集合db.createCollection(tableName) //创建一个集合db.getCollection(tableName) //获取集合的信息 db.collectionName.drop() //删除集合 db.collectionName.renameCollection(newName); //重命名集合 4.用户操作 db.addUser(name,password,true) //添加用户
show users //查看用户5.集合数据操作 db.collection.insert(name:ikasa,age:20) //插入一条数据db.collection.find() //查询说有记录 db.collection.find({age:20}) //age 20db.collection.find({age:{$gt:20}}) //age 20 [$lt ,$gte]db.collection.find({age:{$gt:20,$lte:30}}) //20 and 30db.collection.find({name:name,age:{$gt:20}}) //namename and age20db.collection.find({$or:[{age:20},{name:ikasa}]}) // age 20 or name ikasadb.collection.find({name:/name/}) // like %name%db.collection.find({name:/^name/}) //like name%db.collection.find({name:/name$/}) // like %namedb.collection.find().count();db.collection.find().sort({age:1}) // order by age descdb.collection.find().limit(5)
db.collection.find().limit(5).skip(5) //limit(5,5)db.collection.distinct() // 去除重复的数据列db.collection.find({},{name:1}) //查询字段name//删除db.user.remove({age:20})//更新db.user.update({name:name},{$set:{age:30}},false,true) //update set age30 where name name//添加db.user.insert({name:name}) 转载于:https://www.cnblogs.com/ikasa007/p/4435237.html