Previously there was a replica set to build mongodb3.0, but the admin database that was used directly was the root of the user. Links: http://blog.csdn.net/tuzongxun/article/details/51723259
Recently you want to move data to a non-admin database, and then re-create the user in the non-admin library, the process is roughly the same as before, but there are some problems when creating the user, mainly on the user roles and permissions. I built the process to refer to the following user rights related blogs: http://blog.csdn.net/tuzongxun/article/details/47420149
Root roles and permissions cannot be used I was expecting it before I tried it, but according to the document above, I thought clusteradmin was OK and the result was not.
Finally, a readwrite user is created, successfully connected and used, and can be successfully operated with java-spring. Users create such as:
The Java code writes a simple test class connection query (which can refer to the code in the first link at the beginning), and the result of successful connection operation
mongodb3.0 Replica Set Build Supplement ~ ~ User Rights for non-admin database