1、打开终端窗口。

2、sudo service mongod start开启服务。

3、输入mongo进入mongodb。

4、use 数据库名,这样可以创建数据库。

5、db.createCollection("")
创建集合。

6、db.集合.drop()
删除集合。

7、db.createCollection().count()查询记录条数。

8、show collections
查看所有集合。

时间:2026-04-26 11:32:58
1、打开终端窗口。

2、sudo service mongod start开启服务。

3、输入mongo进入mongodb。

4、use 数据库名,这样可以创建数据库。

5、db.createCollection("")
创建集合。

6、db.集合.drop()
删除集合。

7、db.createCollection().count()查询记录条数。

8、show collections
查看所有集合。
