forked from docs/doc-exports
Reviewed-by: Boka, Ladislav <ladislav.boka@t-systems.com> Co-authored-by: Wang , Deng Ke <wangdengke2@huawei.com> Co-committed-by: Wang , Deng Ke <wangdengke2@huawei.com>
51 lines
7.5 KiB
HTML
51 lines
7.5 KiB
HTML
<a name="dds_03_0057"></a><a name="dds_03_0057"></a>
|
|
|
|
<h1 class="topictitle1">Creating a Database Account Using Commands</h1>
|
|
<div id="body1493258332713"><div class="section" id="dds_03_0057__section6515110014278"><h4 class="sectiontitle">Scenarios</h4><div class="p" id="dds_03_0057__p23852680142710">This section describes how to create a database account and change the account password using commands after the DDS DB instances are created. <div class="note" id="dds_03_0057__note2141534317832"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="dds_03_0057__p5852036517832">When creating a database account for a specified DB instance, you are advised to enable the SSL connection to improve data security.</p>
|
|
</div></div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="dds_03_0057__section42310965142628"><h4 class="sectiontitle"><strong id="dds_03_0057__en-us_topic_0040236005_en-us_topic_0035268496_b842352706102921">Prerequisites</strong></h4><div class="p" id="dds_03_0057__p2059545110103">A <span class="keyword" id="dds_03_0057__keyword1938101913518">DDS DB instance</span> has been connected.<ul id="dds_03_0057__ul358374413114"><li id="dds_03_0057__li558344401111">For details on how to connect to a cluster instance, see <a href="en-us_topic_0044018334.html">Connecting to a Cluster Instance Over Private Networks</a>.</li><li id="dds_03_0057__li3583544161111">For details on how to connect to a replica set instance, see <a href="en-us_topic_0105284966.html">Connecting to a Replica Set Instance Over Private Networks</a>.</li><li id="dds_03_0057__li7391534111219">For details on how to connect to a single node instance, see <a href="dds_02_0028.html">Connecting to a Single Node Instance Over Private Networks</a>.</li></ul>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="dds_03_0057__section21810854151259"><h4 class="sectiontitle">Account Description</h4><p id="dds_03_0057__p40270917151317">To manage DDS DB instances, users <strong id="dds_03_0057__b5402310135914">root</strong>, <strong id="dds_03_0057__b15402010155910">monitor</strong>, and <strong id="dds_03_0057__b11404171010598">backup</strong> are automatically created when you create a DDS DB instance. Attempting to delete, rename, change the passwords, or change privileges for these accounts will result in errors.</p>
|
|
<p id="dds_03_0057__p4774186010851">You can change the password of the database administrator <strong id="dds_03_0057__b842352706144523">rwuser</strong> and any accounts you create.</p>
|
|
</div>
|
|
<div class="section" id="dds_03_0057__section330367810910"><h4 class="sectiontitle">Setting Password Strength for Database Accounts</h4><ul id="dds_03_0057__ul6627138310910"><li id="dds_03_0057__li3688192183014">The administrator password must meet the following password policy:<ul id="dds_03_0057__ul183390211414"><li id="dds_03_0057__li1474213558312">Contains 8 to 32 characters.</li><li id="dds_03_0057__li974305518313">Must be a combination of uppercase letters, lowercase letters, digits, and special characters: ~!@#%^*-_=+?</li></ul>
|
|
</li><li id="dds_03_0057__li682377210910">The database user created on the client must meet the following password policy:<ul id="dds_03_0057__ul6141395510910"><li id="dds_03_0057__li1585468510910">Contains 8 to 32 characters.</li><li id="dds_03_0057__li847444510910">Must be a combination of uppercase letters, lowercase letters, digits, and special characters: ~@#%-_!*+=^?</li></ul>
|
|
</li></ul>
|
|
<p id="dds_03_0057__p916114710910">When you create a DB instance, DDS automatically checks your password strength. You can change the password as user <strong id="dds_03_0057__b842352706111341">rwuser</strong>. For security reasons, you are advised to set up a strong password.</p>
|
|
</div>
|
|
<div class="section" id="dds_03_0057__section2493797710952"><h4 class="sectiontitle">Creating an Account</h4><ol id="dds_03_0057__ol671027910952"><li id="dds_03_0057__li20992131415379"><span>Log in to the DDS.</span></li><li id="dds_03_0057__li6039251210952"><span>Run the following command to select the admin database:</span><p><p id="dds_03_0057__p666170110952"><strong id="dds_03_0057__b5995530910952">use admin</strong></p>
|
|
</p></li><li id="dds_03_0057__li272687510952"><span>Run the following command to create a database account (<strong id="dds_03_0057__b2049612515286">user1</strong> as an example):</span><p><p id="dds_03_0057__p2454187910952"><strong id="dds_03_0057__b104240246433">db.createUser({user: "user1", pwd: "</strong><em id="dds_03_0057__i03468155136"><strong id="dds_03_0057__b1591163015132">**********</strong></em><strong id="dds_03_0057__b178881133124314">", passwordDigestor:"</strong><strong id="dds_03_0057__b355192505015">server</strong><strong id="dds_03_0057__b389083320433">", roles:[{role: "root", db: "admin"}]})</strong></p>
|
|
<ul id="dds_03_0057__ul4173517310952"><li id="dds_03_0057__li4007224110952"><em id="dds_03_0057__i842352697172856"><strong id="dds_03_0057__b842352706172847">server</strong></em>: indicates that the password is encrypted on the server.</li><li id="dds_03_0057__li4855815410952"><em id="dds_03_0057__i842352697115654"><strong id="dds_03_0057__b842352706144749">roles</strong></em> restrict the rights of the account. If an empty array is specified, the account does not have any permission.</li></ul>
|
|
</p></li><li id="dds_03_0057__li3437020310952"><span>Check the result:</span><p><p id="dds_03_0057__p4089637110952">The account is successfully created if the following information is displayed:</p>
|
|
<pre class="screen" id="dds_03_0057__screen3252301910952">Successfully added user: {
|
|
"user" : "user1",
|
|
"passwordDigestor" : "server",
|
|
"roles" : [
|
|
{
|
|
"role" : "root",
|
|
"db" : "admin"
|
|
}
|
|
]
|
|
}</pre>
|
|
</p></li></ol>
|
|
</div>
|
|
<div class="section" id="dds_03_0057__section44669932101727"><h4 class="sectiontitle">Changing a Password</h4><ol id="dds_03_0057__o12386b3d9147482881ddfdfd9a3f787c"><li id="dds_03_0057__li15100131944114"><span>Log in to the DDS.</span></li><li id="dds_03_0057__li44786699134732"><span>Run the following command to select the admin database:</span><p><p id="dds_03_0057__p47457077132312"><strong id="dds_03_0057__b41899896132322">use admin</strong></p>
|
|
</p></li><li id="dds_03_0057__lf50bb4c0b07747cfac89f74cc2b28b4a"><span>Uses user <strong id="dds_03_0057__b84235270614565">user1</strong> as an example. Run the following command to change its password:</span><p><p id="dds_03_0057__p33083474132326"><strong id="dds_03_0057__b18626747132339">db.updateUser("user1", {passwordDigestor:"server",pwd:"**********"})</strong></p>
|
|
<p id="dds_03_0057__p183681571715"><em id="dds_03_0057__i2075236688"><strong id="dds_03_0057__b1331466340">server</strong></em>: indicates that the password is encrypted on the server.</p>
|
|
</p></li><li id="dds_03_0057__li23204344132351"><span>Check the setting result. The password is successfully changed if the following information is displayed:</span><p><ul id="dds_03_0057__ul18161746175515"><li id="dds_03_0057__li417646185510">Cluster<pre class="screen" id="dds_03_0057__screen141854665519">mongos></pre>
|
|
</li><li id="dds_03_0057__li1220246105512">Replica set<pre class="screen" id="dds_03_0057__screen168161854104">replica:PRIMARY></pre>
|
|
</li><li id="dds_03_0057__li96644381719">Single node<pre class="screen" id="dds_03_0057__en-us_topic_0085335430_screen65328077132458">replica:PRIMARY></pre>
|
|
</li></ul>
|
|
</p></li></ol>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dds_03_0001.html">Account Management</a></div>
|
|
</div>
|
|
</div>
|
|
|