In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Editor to share with you how MongoDB can not create users in the system database local, I believe most people do not know much about it, so share this article for your reference. I hope you will gain a lot after reading this article. Let's learn about it together.
Preface
We know that MongoDB's Oplog (operations log) records the user's most recent operations (the length of time is mainly affected by the set oplogSize and the number of write updates to the program). So, if other departments (such as the BI team) need to extract data, it's a good choice to read and parse from local.oplog.rs.
Oplog is located under the local data. In order to minimize permissions, you need to create permissions for this library (you can also refine the permissions to a collection and not discuss them again).
Habitually, it was created under the local database, but the error was reported.
Execute script
Db.createUser ({user: "testuser_local", pwd: "testuser_local", roles: [{role: "read", db: "local"}]})
Error message
2018-XX-XXT14:48:30.437+0800 E QUERY [thread1] Error: couldn't add user: Cannot create users in the local database:
_ getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1290:15
@ (shell): 1:1
Check the description of mongoDB's official website and find that it is really not possible to create an account under the local database.
Solution
The solution is to go to the admin database and create an account.
It can be created successfully at this time.
Note: (1) when configuring the connection string on the program side, you need to add the login verification database parameter-authenticationDatabase admin
(2) when logging in through NoSQLBooster, Auth DB selects the name of the database to execute the creation command (this example is admin)
Edit item of Default Database and select the local database where oplog is located.
Log in successfully
However, during the testing process, it was found that the login of the tool could be successful under this small permission, but sometimes the execution of the command was wrong, and the execution through MongoDB shell did not report an error. The root cause still needs to be explored)
(3) it is recommended that the data should be pulled on the secondary node to reduce the pressure on the main database.
These are all the contents of the article "what to do if MongoDB cannot create users in the system database local". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
SQL > set lines 200SQL > select * from v$version where rownum=1;BANNER
© 2024 shulou.com SLNews company. All rights reserved.