工具: mongodb、mongoose
MongoDB云数据库Atlas使用
云远程
const MongoClient = require('mongodb').MongoClient;const uri = "mongodb+srv://zhaocchen:<password>@cluster0.tjac2.mongodb.net/myFirstDatabase?retryWrites=true&w=majority";const client = new MongoClient(uri, { useNewUrlParser: true, useUnifiedTopology: true });client.connect(err => {const collection = client.db("test").collection("devices");// perform actions on the collection objectclient.close();});
安装
netstat -lanp | grep "27017"whereis mongodb
安装错误
// error./mongod: error while loading shared libraries: libcrypto.so.1.0.0: cannot open shared object file: No such file or directory// 查看需要哪些依赖ldd /usr/local/mongodb4/bin/mongodlibcrypto.so.1.0.0 => not foundlibssl.so.1.0.0 => not foundlibc.so.6 => /lib64/libc.so.6 (0x00007fc1fec04000)// 设置软连接ln -s /usr/lib/libcrypto.so.1.0.0 /lib64/libcrypto.so.1.0.0ln -s /usr/lib/libssl.so.1.0.0 /lib64/libssl.so.1.0.0// 删除软连接rm -rf /lib64/libssl.so.1.0.0yum whatprovides libcrypto.so.1.0.0
https://www.jianshu.com/p/d403f5bbc58e
