Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (47.6k points)

I firstly installed MongoDB 3.4.1 today. But when I start it and use MongoDB shell, it gave me these warnings below:

C:\Users\hs>"C:\Program Files\MongoDB\Server\3.4\bin\mongo.exe MongoDB shell version v3.4.1 connecting to: mongodb://127.0.0.1:27017 MongoDB server version: 3.4.1 Server has startup warnings: 2017-01-12T21:19:46.941+0800 I CONTROL [initandlisten] 2017-01-12T21:19:46.942+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database. 2017-01-12T21:19:46.942+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted. 2017-01-12T21:19:46.942+0800 I CONTROL [initandlisten]

my computer is Microsoft Windows [version 10.0.14393].

2 Answers

0 votes
by (106k points)

You need to delete your old db folder and recreate a new one. It will resolve your issue.

0 votes
by (108k points)
  • You need to perform the following steps to create a secure database:

  • Start MongoDB without access control.

  • Connect to the instance.

  • Create the user administrator (in the admin authentication database) like  the following:

use ad

db.createUser(

  {

    user: "myUserAdmin",

    pwd: "abc123",

    roles: [ { role: "userAdminAnyDatabase", db: "ad" } ]

  }

)

  • Re-start the MongoDB instance with access control.

  • Connect and authenticate as the user administrator.

  • Now create additional users as needed for your deployment (e.g. in the test authentication database).

use test

db.createUser(

  {

    user: "myTester",

    pwd: "xyz123",

    roles: [ { role: "readWrite", db: "test" },

             { role: "read", db: "reporting" } ]

  }

)

  • At last connect and authenticate as the user(myTester).

Related questions

0 votes
1 answer
asked Feb 9, 2020 in Web Technology by ashely (50.2k points)
0 votes
1 answer
asked Feb 13, 2020 in Web Technology by ashely (50.2k points)
0 votes
1 answer

Browse Categories

...