Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

latest verison of mongoDB provided by docker, should use auth uri to connect #2

Open
Steven0038 opened this issue May 4, 2022 · 0 comments

Comments

@Steven0038
Copy link

Steven0038 commented May 4, 2022

As title, the lastest version of mongo, not allow seperate setting under application properties and cause authentication errors.

ref.

If you use the Mongo 3.0 Java driver, spring.data.mongodb.host and spring.data.mongodb.port are not supported. In such cases, spring.data.mongodb.uri should be used to provide all of the configuration.

The following uri setting works.

spring.data.mongodb.uri=mongodb://admin:123456@localhost:27017/spring_boot_mongo_app?authSource=admin&readPreference=primary&appname=MongoDB%20Compass&ssl=false

Before starts the app, should run the following commands to create db admin with user name as admin and password as 123456.

docker exec -it mongo mongo admin
db.createUser({ user:'admin',pwd:'123456',roles:[ { role:'userAdminAnyDatabase', db: 'admin'},"readWriteAnyDatabase"]}

code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant