Quantcast
Channel: Active questions tagged amazon-ec2 - Stack Overflow
Viewing all articles
Browse latest Browse all 29444

MongoDB: unable to create admin user

$
0
0

When I try to list all databases, I receive this error:

2019-10-09T17:26:29.636+0000 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:814:19
shellHelper@src/mongo/shell/utils.js:704:15

So, I tried to create an admin user with this command:

db.createUser( { user: 'admin', pwd: 'password', roles: [ { role: 'root', db: 'team' } ] } ); exit;

And I receive this error:

2019-10-09T17:31:42.303+0000 E QUERY    [thread1] Error: couldn't add user: not authorized on admin to execute command { createUser: "admin", pwd: "xxx", roles: [ { role: "root", db: "team" } ], digestPassword: false, writeConcern: { w: "majority", wtimeout: 600000.0 } } :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1292:15
@(shell):1:1
> 

I want to be able to create an admin user or enable permissions for me to be able to list all databases.

This is on an Amazon EC2 instance.

I also tried this: MongoDB: Not authorized on admin to execute command

When I try to run to run mongod --auth, I receive this error:

2019-10-09T17:35:29.442+0000 I CONTROL  [initandlisten] MongoDB starting : pid=7372 port=27017 dbpath=/data/db 64-bit host=ip-172-31-104-209.ec2.internal
2019-10-09T17:35:29.442+0000 I CONTROL  [initandlisten] db version v3.4.23
2019-10-09T17:35:29.442+0000 I CONTROL  [initandlisten] git version: 324017ede1dbb1c9554dd2dceb15f8da3c59d0e8
2019-10-09T17:35:29.442+0000 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.0-fips 29 Mar 2010
2019-10-09T17:35:29.442+0000 I CONTROL  [initandlisten] allocator: tcmalloc
2019-10-09T17:35:29.442+0000 I CONTROL  [initandlisten] modules: none
2019-10-09T17:35:29.442+0000 I CONTROL  [initandlisten] build environment:
2019-10-09T17:35:29.442+0000 I CONTROL  [initandlisten]     distmod: amazon
2019-10-09T17:35:29.442+0000 I CONTROL  [initandlisten]     distarch: x86_64
2019-10-09T17:35:29.443+0000 I CONTROL  [initandlisten]     target_arch: x86_64
2019-10-09T17:35:29.443+0000 I CONTROL  [initandlisten] options: { security: { authorization: "enabled" } }
2019-10-09T17:35:29.443+0000 I STORAGE  [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
2019-10-09T17:35:29.443+0000 I NETWORK  [initandlisten] shutdown: going to close listening sockets...
2019-10-09T17:35:29.443+0000 I NETWORK  [initandlisten] shutdown: going to flush diaglog...
2019-10-09T17:35:29.443+0000 I CONTROL  [initandlisten] now exiting
2019-10-09T17:35:29.443+0000 I CONTROL  [initandlisten] shutting down with code:100

Viewing all articles
Browse latest Browse all 29444

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>