MongoDB - admin user not authorized on sandbox plan











up vote
0
down vote

favorite












I am trying to upgrade my sandbox database server version to 4.x.x. It is now at 3.6.6



In order to do that, I need to create an admin user.



So I connect to the mongo shell and I run the following :



db.createUser( { user: "admin", pwd: "password", roles: [ { role: "root", db: "mydatabasename" } ] } );


However, I get the following error :



Error: couldn't add user: not authorized on admin to execute command 


It's been hours I am trying to figure out this issue. Other stackoverflow related questions don't solve it.



I am wondering if it is even possible to do so on a non dedicated database server. If not, how can I upgrade the server version ?



Any help would be greatly appreciated.










share|improve this question




























    up vote
    0
    down vote

    favorite












    I am trying to upgrade my sandbox database server version to 4.x.x. It is now at 3.6.6



    In order to do that, I need to create an admin user.



    So I connect to the mongo shell and I run the following :



    db.createUser( { user: "admin", pwd: "password", roles: [ { role: "root", db: "mydatabasename" } ] } );


    However, I get the following error :



    Error: couldn't add user: not authorized on admin to execute command 


    It's been hours I am trying to figure out this issue. Other stackoverflow related questions don't solve it.



    I am wondering if it is even possible to do so on a non dedicated database server. If not, how can I upgrade the server version ?



    Any help would be greatly appreciated.










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I am trying to upgrade my sandbox database server version to 4.x.x. It is now at 3.6.6



      In order to do that, I need to create an admin user.



      So I connect to the mongo shell and I run the following :



      db.createUser( { user: "admin", pwd: "password", roles: [ { role: "root", db: "mydatabasename" } ] } );


      However, I get the following error :



      Error: couldn't add user: not authorized on admin to execute command 


      It's been hours I am trying to figure out this issue. Other stackoverflow related questions don't solve it.



      I am wondering if it is even possible to do so on a non dedicated database server. If not, how can I upgrade the server version ?



      Any help would be greatly appreciated.










      share|improve this question















      I am trying to upgrade my sandbox database server version to 4.x.x. It is now at 3.6.6



      In order to do that, I need to create an admin user.



      So I connect to the mongo shell and I run the following :



      db.createUser( { user: "admin", pwd: "password", roles: [ { role: "root", db: "mydatabasename" } ] } );


      However, I get the following error :



      Error: couldn't add user: not authorized on admin to execute command 


      It's been hours I am trying to figure out this issue. Other stackoverflow related questions don't solve it.



      I am wondering if it is even possible to do so on a non dedicated database server. If not, how can I upgrade the server version ?



      Any help would be greatly appreciated.







      mongodb mlab






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 11 at 15:08

























      asked Nov 11 at 12:12









      Louis

      13812




      13812
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          If this is first ever user you're trying to connect in DB, you need to use "Localhost Exception":




          The localhost exception allows you to enable access control and then
          create the first user in the system. With the localhost exception,
          after you enable access control, connect to the localhost interface
          and create the first user in the admin database. The first user must
          have privileges to create other users, such as a user with the
          userAdmin or userAdminAnyDatabase role




          Create a user as follows:



          use admin;
          db.createUser( { user: "userAdminAnyDB", pwd: "password", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] } );

          db.auth("userAdminAnyDB", "password")


          Once you successfully login using userAdminAnyDB credentials, create a required for your Db deployment.



          db.createUser( { user: "admin", pwd: "password", roles: [ { role: "root", db: "mydatabasename" } ] } );





          share|improve this answer





















          • Thank you for your answer ! How do I use Localhost Exception ?
            – Louis
            Nov 11 at 14:47












          • Following the first set of commands, I get : Error: couldn't add user: not authorized on mydatabasename to execute command { createUser: "userAdminAnyDB", pwd: "xxx", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
            – Louis
            Nov 11 at 14:48










          • I am using mlab and have already 2 users created via mlab but I doubt they have admin privileges. I am not even sure if this is the same users we're talking about via mongo shell
            – Louis
            Nov 11 at 14:53










          • If users are already created, you need to login using user who has privileges to create user and grant admin privileges
            – Astro
            Nov 11 at 14:55










          • None of them has admin privileges. I am not allowed to grant them admin privileges neither (error raised)
            – Louis
            Nov 11 at 14:57











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53248634%2fmongodb-admin-user-not-authorized-on-sandbox-plan%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          If this is first ever user you're trying to connect in DB, you need to use "Localhost Exception":




          The localhost exception allows you to enable access control and then
          create the first user in the system. With the localhost exception,
          after you enable access control, connect to the localhost interface
          and create the first user in the admin database. The first user must
          have privileges to create other users, such as a user with the
          userAdmin or userAdminAnyDatabase role




          Create a user as follows:



          use admin;
          db.createUser( { user: "userAdminAnyDB", pwd: "password", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] } );

          db.auth("userAdminAnyDB", "password")


          Once you successfully login using userAdminAnyDB credentials, create a required for your Db deployment.



          db.createUser( { user: "admin", pwd: "password", roles: [ { role: "root", db: "mydatabasename" } ] } );





          share|improve this answer





















          • Thank you for your answer ! How do I use Localhost Exception ?
            – Louis
            Nov 11 at 14:47












          • Following the first set of commands, I get : Error: couldn't add user: not authorized on mydatabasename to execute command { createUser: "userAdminAnyDB", pwd: "xxx", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
            – Louis
            Nov 11 at 14:48










          • I am using mlab and have already 2 users created via mlab but I doubt they have admin privileges. I am not even sure if this is the same users we're talking about via mongo shell
            – Louis
            Nov 11 at 14:53










          • If users are already created, you need to login using user who has privileges to create user and grant admin privileges
            – Astro
            Nov 11 at 14:55










          • None of them has admin privileges. I am not allowed to grant them admin privileges neither (error raised)
            – Louis
            Nov 11 at 14:57















          up vote
          0
          down vote













          If this is first ever user you're trying to connect in DB, you need to use "Localhost Exception":




          The localhost exception allows you to enable access control and then
          create the first user in the system. With the localhost exception,
          after you enable access control, connect to the localhost interface
          and create the first user in the admin database. The first user must
          have privileges to create other users, such as a user with the
          userAdmin or userAdminAnyDatabase role




          Create a user as follows:



          use admin;
          db.createUser( { user: "userAdminAnyDB", pwd: "password", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] } );

          db.auth("userAdminAnyDB", "password")


          Once you successfully login using userAdminAnyDB credentials, create a required for your Db deployment.



          db.createUser( { user: "admin", pwd: "password", roles: [ { role: "root", db: "mydatabasename" } ] } );





          share|improve this answer





















          • Thank you for your answer ! How do I use Localhost Exception ?
            – Louis
            Nov 11 at 14:47












          • Following the first set of commands, I get : Error: couldn't add user: not authorized on mydatabasename to execute command { createUser: "userAdminAnyDB", pwd: "xxx", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
            – Louis
            Nov 11 at 14:48










          • I am using mlab and have already 2 users created via mlab but I doubt they have admin privileges. I am not even sure if this is the same users we're talking about via mongo shell
            – Louis
            Nov 11 at 14:53










          • If users are already created, you need to login using user who has privileges to create user and grant admin privileges
            – Astro
            Nov 11 at 14:55










          • None of them has admin privileges. I am not allowed to grant them admin privileges neither (error raised)
            – Louis
            Nov 11 at 14:57













          up vote
          0
          down vote










          up vote
          0
          down vote









          If this is first ever user you're trying to connect in DB, you need to use "Localhost Exception":




          The localhost exception allows you to enable access control and then
          create the first user in the system. With the localhost exception,
          after you enable access control, connect to the localhost interface
          and create the first user in the admin database. The first user must
          have privileges to create other users, such as a user with the
          userAdmin or userAdminAnyDatabase role




          Create a user as follows:



          use admin;
          db.createUser( { user: "userAdminAnyDB", pwd: "password", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] } );

          db.auth("userAdminAnyDB", "password")


          Once you successfully login using userAdminAnyDB credentials, create a required for your Db deployment.



          db.createUser( { user: "admin", pwd: "password", roles: [ { role: "root", db: "mydatabasename" } ] } );





          share|improve this answer












          If this is first ever user you're trying to connect in DB, you need to use "Localhost Exception":




          The localhost exception allows you to enable access control and then
          create the first user in the system. With the localhost exception,
          after you enable access control, connect to the localhost interface
          and create the first user in the admin database. The first user must
          have privileges to create other users, such as a user with the
          userAdmin or userAdminAnyDatabase role




          Create a user as follows:



          use admin;
          db.createUser( { user: "userAdminAnyDB", pwd: "password", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] } );

          db.auth("userAdminAnyDB", "password")


          Once you successfully login using userAdminAnyDB credentials, create a required for your Db deployment.



          db.createUser( { user: "admin", pwd: "password", roles: [ { role: "root", db: "mydatabasename" } ] } );






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 11 at 13:22









          Astro

          2,0312923




          2,0312923












          • Thank you for your answer ! How do I use Localhost Exception ?
            – Louis
            Nov 11 at 14:47












          • Following the first set of commands, I get : Error: couldn't add user: not authorized on mydatabasename to execute command { createUser: "userAdminAnyDB", pwd: "xxx", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
            – Louis
            Nov 11 at 14:48










          • I am using mlab and have already 2 users created via mlab but I doubt they have admin privileges. I am not even sure if this is the same users we're talking about via mongo shell
            – Louis
            Nov 11 at 14:53










          • If users are already created, you need to login using user who has privileges to create user and grant admin privileges
            – Astro
            Nov 11 at 14:55










          • None of them has admin privileges. I am not allowed to grant them admin privileges neither (error raised)
            – Louis
            Nov 11 at 14:57


















          • Thank you for your answer ! How do I use Localhost Exception ?
            – Louis
            Nov 11 at 14:47












          • Following the first set of commands, I get : Error: couldn't add user: not authorized on mydatabasename to execute command { createUser: "userAdminAnyDB", pwd: "xxx", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
            – Louis
            Nov 11 at 14:48










          • I am using mlab and have already 2 users created via mlab but I doubt they have admin privileges. I am not even sure if this is the same users we're talking about via mongo shell
            – Louis
            Nov 11 at 14:53










          • If users are already created, you need to login using user who has privileges to create user and grant admin privileges
            – Astro
            Nov 11 at 14:55










          • None of them has admin privileges. I am not allowed to grant them admin privileges neither (error raised)
            – Louis
            Nov 11 at 14:57
















          Thank you for your answer ! How do I use Localhost Exception ?
          – Louis
          Nov 11 at 14:47






          Thank you for your answer ! How do I use Localhost Exception ?
          – Louis
          Nov 11 at 14:47














          Following the first set of commands, I get : Error: couldn't add user: not authorized on mydatabasename to execute command { createUser: "userAdminAnyDB", pwd: "xxx", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
          – Louis
          Nov 11 at 14:48




          Following the first set of commands, I get : Error: couldn't add user: not authorized on mydatabasename to execute command { createUser: "userAdminAnyDB", pwd: "xxx", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
          – Louis
          Nov 11 at 14:48












          I am using mlab and have already 2 users created via mlab but I doubt they have admin privileges. I am not even sure if this is the same users we're talking about via mongo shell
          – Louis
          Nov 11 at 14:53




          I am using mlab and have already 2 users created via mlab but I doubt they have admin privileges. I am not even sure if this is the same users we're talking about via mongo shell
          – Louis
          Nov 11 at 14:53












          If users are already created, you need to login using user who has privileges to create user and grant admin privileges
          – Astro
          Nov 11 at 14:55




          If users are already created, you need to login using user who has privileges to create user and grant admin privileges
          – Astro
          Nov 11 at 14:55












          None of them has admin privileges. I am not allowed to grant them admin privileges neither (error raised)
          – Louis
          Nov 11 at 14:57




          None of them has admin privileges. I am not allowed to grant them admin privileges neither (error raised)
          – Louis
          Nov 11 at 14:57


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53248634%2fmongodb-admin-user-not-authorized-on-sandbox-plan%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Xamarin.iOS Cant Deploy on Iphone

          Glorious Revolution

          Dulmage-Mendelsohn matrix decomposition in Python