<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Andrei Radulescu on Medium]]></title>
        <description><![CDATA[Stories by Andrei Radulescu on Medium]]></description>
        <link>https://medium.com/@andiradulescu?source=rss-9f0372e6bebf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Ct3ElrAWrjOyfn8A.jpg</url>
            <title>Stories by Andrei Radulescu on Medium</title>
            <link>https://medium.com/@andiradulescu?source=rss-9f0372e6bebf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 11:00:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@andiradulescu/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to secure MongoDB in 3 easy steps with Authentication]]></title>
            <link>https://andiradulescu.medium.com/how-to-secure-mongodb-in-3-easy-steps-with-authentication-5bf78d0536ac?source=rss-9f0372e6bebf------2</link>
            <guid isPermaLink="false">https://medium.com/p/5bf78d0536ac</guid>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[cloud-services]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Andrei Radulescu]]></dc:creator>
            <pubDate>Wed, 06 Feb 2019 19:57:49 GMT</pubDate>
            <atom:updated>2019-02-26T15:05:07.411Z</atom:updated>
            <content:encoded><![CDATA[<p>This assumes you have MongoDB already installed.</p><h3><strong>Step 1 — Adding an admin user</strong></h3><p>Open a shell and run the MongoDB client.</p><pre>$ mongo</pre><p>Copy the following snippet. Change the <strong>password</strong> field, then paste it to the shell. You can also change the name of the admin user but don’t touchroles.</p><pre>use admin<br>db.createUser(<br>  {<br>    user: &quot;admin&quot;,<br>    pwd: &quot;<strong>password</strong>&quot;,<br>    roles: [ { role: &quot;userAdminAnyDatabase&quot;, db: &quot;admin&quot; } ]<br>  }<br>)</pre><p>Press Enter, then mongo will reply with “Successfully added user: …”. Then type ‘exit’ or use CTRL+C.</p><h3>Step 2 — Enabling Authentication</h3><p>Edit mongod.conf with your preferred editor and enable authorization.</p><pre>$ sudo vi /etc/mongod.conf</pre><p>In the security section, remove any #, then change authorization toenabled or add it if it’s missing. It should look like this:</p><pre>security:<br>  authorization: &quot;enabled&quot;</pre><p>If there is no mongod.conf file, or it’s empty, then you probably need to consider upgrading to a more recent version of MongoDB. But, if you don’t care, just do this:</p><pre>$ sudo vi /etc/mongodb.conf</pre><p>Look for auth, remove # and be sure it’strue. It should look like this:</p><pre>auth = true</pre><p>Then restart the mongod (or mongodb) service:</p><pre>sudo systemctl restart mongod (mongodb in the 2nd case)</pre><h3>Step 3 — Create a user</h3><p>This is the user your app will be using to connect to MongoDB.</p><p>So, login with the admin user created in <strong>Step 1</strong>:</p><pre>$ mongo -u admin -p --authenticationDatabase admin</pre><p>Then, similar to Step 1, copy the creating user snippet below. Change <strong>database-name</strong>, <strong>user-name</strong> and <strong>user-password</strong> (don’t forget the 2nd <strong>database-name</strong> in roles) and paste it in the shell:</p><pre>use <strong>database-name</strong><br>db.createUser(<br>  {<br>    user: &quot;<strong>user-name</strong>&quot;,<br>    pwd: &quot;<strong>user-password</strong>&quot;,<br>    roles: [ { role: &quot;readWrite&quot;, db: &quot;<strong>database-name</strong>&quot; } ]<br>  }<br>)</pre><p>Press Enter, then mongo will reply with “Successfully added user: …”. Then type ‘exit’ or use CTRL+C.</p><p><strong>And that’s it!</strong></p><p>For your app to connect, it will use a Connection String URI. The standard looks like this:</p><pre>mongodb://user:password@ip:port/database</pre><p>You need to replace user, password, ip, port and database with the correct values including the credentials created in <strong>Step 3</strong>.</p><p>If you also use <strong>Robo 3T</strong>, you can configure it by editing the <strong>Authentication</strong> tab, checking “<strong>Perform authentication</strong>” and then copy &amp; pasting the credentials from <strong>Step 3</strong> in the <strong>Database</strong>, <strong>User Name</strong> and <strong>Password</strong> fields.</p><h3>More reading:</h3><p>How to Enable Authentication on MongoDB <a href="https://medium.com/mongoaudit/how-to-enable-authentication-on-mongodb-b9e8a924efac">https://medium.com/mongoaudit/how-to-enable-authentication-on-mongodb-b9e8a924efac</a></p><p>How to Upgrade MongoDB to Latest Stable Version <a href="https://medium.com/mongoaudit/how-to-upgrade-mongodb-to-latest-stable-version-9607266834cf">https://medium.com/mongoaudit/how-to-upgrade-mongodb-to-latest-stable-version-9607266834cf</a></p><p>MongoDB One-Click Application — DigitalOcean <a href="https://www.digitalocean.com/products/one-click-apps/mongodb/?refcode=8c96c172a094">https://www.digitalocean.com/products/one-click-apps/mongodb/?refcode=8c96c172a094</a></p><blockquote>If you don’t have a DigitalOcean account, you can sign-up from the MongoDB One-Click Application page above(it has a referral code embedded in the link) and it will give you $100 in credit over 60 days and give me $25 once you spend more than $25. Terms might change over time. Thanks!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5bf78d0536ac" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>