I’ve tried to get up-and-running with a small MongoDB web application. I need to connect to a fresh mongodb on every CI run. I cannot connect. What am I missing?
Here is my config.yml:
version: 2.1 orbs: node: email@example.com jobs: build: # pre-built images: https://circleci.com/docs/2.0/circleci-images/ docker: - image: circleci/node:10-browsers - image: circleci/mongo:3.6 environment: - MONGODB_USERNAME: mongouser - MONGODB_PASSWORD: mongopass steps: - setup_remote_docker - run: name: Waiting for Mongo command: dockerize -wait tcp://localhost:27017 -timeout 1m - run: name: Install mongo client command: | sudo apt-get install -y mongodb - checkout - run: name: Connect to DB command: mongo --username mongouser --password mongopass --eval "printjson(db.apikeys.count());" dbname
And here is the error in the “Connect to DB” step:
#!/bin/bash -eo pipefail mongo --username=mongouser --password=mongopass --eval "printjson(db.apikeys.count());" dbname MongoDB shell version: 3.2.11 connecting to: dbname 2021-04-01T17:13:49.031+0000 E QUERY [thread1] Error: Authentication failed. : DB.prototype._authOrThrow@src/mongo/shell/db.js:1441:20 @(auth):6:1 @(auth):1:2 exception: login failed Exited with code exit status 1 CircleCI received exit code 1
I’ve noticed there are a lot of questions here about getting up and running with a Mongo app, not a lot of good answers. I want to use Mongo 4.x but cannot figure out how to install the db tools alone. So I’ve tried 3.6 and now I can’t authenticate for some reason? What am I missing?