工具: 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 object
client.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/mongod
libcrypto.so.1.0.0 => not found
libssl.so.1.0.0 => not found
libc.so.6 => /lib64/libc.so.6 (0x00007fc1fec04000)
// 设置软连接
ln -s /usr/lib/libcrypto.so.1.0.0 /lib64/libcrypto.so.1.0.0
ln -s /usr/lib/libssl.so.1.0.0 /lib64/libssl.so.1.0.0
// 删除软连接
rm -rf /lib64/libssl.so.1.0.0
yum whatprovides libcrypto.so.1.0.0
https://www.jianshu.com/p/d403f5bbc58e