当前位置:Gxlcms > 数据库问题 > mongodb基本操作

mongodb基本操作

时间:2021-07-01 10:21:17 帮助过:4人阅读

sz1905 => {student,teacher}    

  student =>{xiaomig,zhangsan,lisi}

1.mongod --dbpath c:\data\db                    //cmd启动。不能关    正确的显示waiting for connections on port 27017

2再开启 另外一个窗口
cmd全局下运行 mongo       git也可以,中文方便(一般在user目录下运行)     //正确显示  MongoDB shell version: 3.2.14-rc1                           

                                        connecting to: test

常用命令:

 ctrl +c,命令返回上级

show dbs 显示全部数据库 sz1905,local

use sz1905  用这个数据库。(创建或者切换)

db 查看当前使用的数据库    当前没用 则test

db.getMongo()    //connection to 127.0.0.1链接数据库的地址

  完整地址:mongodb://127.0.0.1:27017   http的端口号:80 8080   https端口号:443   mongodb的端口号: 27017 db.createCollection(‘表的名称‘)    创建一张表 db.getCollectionNames()  //查看当前数据库(比如sz1905)下 所有的表 db.getCollection(‘表名‘)   //使用这张表 db.<表名>.find()  //查看这张表的所有内容     增删改查...... node.js 链接数据库

mongodb基本操作

标签:data   hang   cal   path   shel   查看   pat   tco   create   

人气教程排行