时间:2024-02-07 12:09作者:下载吧人气:22
1.mongodb官网
MongoDB: the application data platform | MongoDB
2.进入MongoDB官网下载MongoDB以及MongoDB compass 和Mongodb–database–tools
3.nodejs操作MongoDB数据库需要依赖nodejs的第三方包mongoose
终端指令: npm install mongoose
4.
5.
以管理员身份运行PowerShell cd到文件所在目录 如果没有开启MongoDB的话
使用net start mongodb 指令启动
6.
//引入mongoose模块
const mongoose = require(‘mongoose’);
// console.log(mongoose);
//todo 连接数据库
mongoose.connect(‘mongodb://localhost/test001’)
.then(() => console.log(‘数据库链接成功’))
.catch(erro => console.log(‘连接失败’))
网友评论