mongodb 插入数据报 Command insert requires authentication

40 阅读1分钟

今天使用nodejs连接mongodb并且向mongodb中插入数据,响应结果为 Command insert requires authentication

经过排查,最后发现是在创建连接时漏拼参数了

正确的拼接格式为

mongodb://用户名:密码@host地址:端口/数据库名