MongoDB shell command line authentication fails

后端 未结 2 1946
终归单人心
终归单人心 2021-01-07 17:37

I set up replica set with authentication. I used this tutorial. I set up keyfile, admin user and other users. It all works fine - anonymous access is disabled and I can logi

相关标签:
2条回答
  • 2021-01-07 18:17

    Perhaps different now because of an update since this question was originally answered, but authentication only succeeds when wrapping username/password in double quotes. e.g.,

    mongo admin -u "myName" -p "myPassword"
    
    0 讨论(0)
  • 2021-01-07 18:38

    The in-shell authentication performed in your example is against the admin database. The command line posted above does not specify a database and is therefore authenticating against the default database which is test. Try this instead to authenticate via command line against the admin db:

    mongo admin -u 'USERNAME' -p 'PASSWORD'
    

    if the server is not on the local host then you can use this:

    mongo your_host_name:your_port/admin -u 'USERNAME' -p 'PASSWORD'
    
    0 讨论(0)
提交回复
热议问题