Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- C:mongodbbin>use admin
- db.createUser(
- {
- user: "myUserAdmin",
- pwd: "abc123",
- roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
- }
- )
- C:Windowssystem32>mongo
- MongoDB shell version v3.4.9
- connecting to: mongodb://127.0.0.1:27017
- MongoDB server version: 3.4.9
- Server has startup warnings:
- 2018-03-28T16:53:43.515+0800 I CONTROL [initandlisten]
- 2018-03-28T16:53:43.516+0800 I CONTROL [initandlisten] ** WARNING: Access contr
- ol is not enabled for the database.
- 2018-03-28T16:53:43.516+0800 I CONTROL [initandlisten] ** Read and wri
- te access to data and configuration is unrestricted.
- 2018-03-28T16:53:43.516+0800 I CONTROL [initandlisten]
- 2018-03-28T16:53:43.516+0800 I CONTROL [initandlisten] Hotfix KB2731284 or late
- r update is not installed, will zero-out data files.
- 2018-03-28T16:53:43.516+0800 I CONTROL [initandlisten]
- > show dbs
- admin 0.000GB
- local 0.000GB
- > use admin
- switched to db admin
- >
- C:mongodbbin>sc delete MongoDB
- C:mongodbbin>mongod --dbpath C:mongodbdata --logpath C:mongodblogMongoDB.log --auth --install
- C:Windowssystem32>mongo
- MongoDB shell version v3.4.9
- connecting to: mongodb://127.0.0.1:27017
- MongoDB server version: 3.4.9
- > show dns
- 2018-03-28T17:59:06.344+0800 E QUERY [thread1] Error: don't know how to show
- [dns] :
- shellHelper.show@src/mongo/shell/utils.js:906:11
- shellHelper@src/mongo/shell/utils.js:659:15
- @(shellhelp2):1:1
- > show dbs
- 2018-03-28T17:59:10.073+0800 E QUERY [thread1] Error: listDatabases failed:{
- "ok" : 0,
- "errmsg" : "not authorized on admin to execute command { listDatabases:
- 1.0 }",
- "code" : 13,
- "codeName" : "Unauthorized"
- } :
- _getErrorWithCode@src/mongo/shell/utils.js:25:13
- Mongo.prototype.getDBs@src/mongo/shell/mongo.js:62:1
- shellHelper.show@src/mongo/shell/utils.js:769:19
- shellHelper@src/mongo/shell/utils.js:659:15
- @(shellhelp2):1:1
- >
- C:Windowssystem32>mongod --auth --port 27017 --dbpath C:mongodbdata
- 2018-03-28T16:49:43.874+0800 I CONTROL [initandlisten] MongoDB starting : pid=7
- 988 port=27017 dbpath=C:mongodbdata 64-bit host=wolf-PC
- .....
- 2018-03-28T16:49:43.877+0800 I STORAGE [initandlisten] exception in initAndList
- en: 98 Unable to create/open lock file: C:mongodbdatamongod.lock Another program is using this file.... Is a mongod instance already running?, terminating
- security:
- authorization: enabled
- db.createUser(
- {
- user: <app db user>,
- pwd: <password>,
- roles: [ { role: "readWrite", db: <app db> } ]
- }
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement