<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Database on Nalar</title>
    <link>https://nalar.dev/database/</link>
    <description>Recent content in Database on Nalar</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Tue, 01 Sep 2026 00:00:00 +0700</lastBuildDate>
    <atom:link href="https://nalar.dev/database/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Transaction Isolation and Safe Database Retries</title>
      <link>https://nalar.dev/transaction-isolation-and-safe-retries/</link>
      <pubDate>Tue, 01 Sep 2026 00:00:00 +0700</pubDate>
      <guid>https://nalar.dev/transaction-isolation-and-safe-retries/</guid>
      <description>&lt;p&gt;Database transactions make groups of reads and writes atomic, but atomicity alone does not answer what concurrent transactions are allowed to observe. That is the job of isolation.&lt;/p&gt;&#xA;&lt;p&gt;The practical challenge appears when correct transactions conflict. Strong isolation can intentionally abort one transaction rather than allow an invalid interleaving. Applications need to distinguish those retryable concurrency failures from ordinary errors.&lt;/p&gt;&#xA;&lt;h2 id=&#34;isolation-protects-invariants-not-just-statements&#34;&gt;Isolation protects invariants, not just statements&lt;/h2&gt;&#xA;&lt;p&gt;Consider two concurrent requests that reserve the last available item.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Configuring Remote MySQL Access on Linux</title>
      <link>https://nalar.dev/configuring-remote-mysql-access-on-linux/</link>
      <pubDate>Thu, 29 Sep 2022 00:00:00 +0700</pubDate>
      <guid>https://nalar.dev/configuring-remote-mysql-access-on-linux/</guid>
      <description>&lt;p&gt;MySQL installations are commonly configured to listen only on a local interface. If a database must accept connections from another machine, you need to adjust the server&amp;rsquo;s listening address, create an appropriately scoped account, and make sure the network firewall allows only the required clients.&lt;/p&gt;&#xA;&lt;h3 id=&#34;step-1-update-the-mysql-configuration&#34;&gt;&lt;strong&gt;Step 1: Update the MySQL Configuration&lt;/strong&gt;&lt;/h3&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit the MySQL configuration file&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;On Ubuntu and Debian installations, a common file is:&lt;/p&gt;&#xA;&lt;div &#xA;    x-data=&#34;{&#xA;        code: $el.querySelector(&#39;code&#39;).innerText&#xA;    }&#34;&#xA;    class=&#34;relative my-4 rounded-lg group&#34;&#xA;&gt;&#xA;    &lt;button&#xA;        @click=&#34;navigator.clipboard.writeText(code); $el.innerText = &#39;Copied!&#39;; setTimeout(() =&gt; $el.innerText = &#39;Copy&#39;, 2000)&#34;&#xA;        class=&#34;absolute top-2 right-2 bg-neutral-700 text-white text-xs px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition-opacity&#34;&#xA;    &gt;&#xA;        Copy&#xA;    &lt;/button&gt;&#xA;    &#xA;    &lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#xA;&lt;/div&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;&lt;strong&gt;Change &lt;code&gt;bind-address&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Exporting and Restoring MongoDB Databases with `mongodump` and `mongorestore`</title>
      <link>https://nalar.dev/exporting-and-restoring-mongodb-databases-with-mongodump-and-mongorestore/</link>
      <pubDate>Wed, 06 Oct 2021 00:00:00 +0700</pubDate>
      <guid>https://nalar.dev/exporting-and-restoring-mongodb-databases-with-mongodump-and-mongorestore/</guid>
      <description>&lt;p&gt;Backups are an important part of MongoDB administration. Two standard command-line tools for logical backups and restores are &lt;code&gt;mongodump&lt;/code&gt; and &lt;code&gt;mongorestore&lt;/code&gt;, which work with BSON data and collection metadata.&lt;/p&gt;&#xA;&lt;h3 id=&#34;1-back-up-a-database-with&#34;&gt;&lt;strong&gt;1. Back Up a Database with &lt;code&gt;mongodump&lt;/code&gt;&lt;/strong&gt;&lt;/h3&gt;&#xA;&lt;p&gt;Use &lt;code&gt;mongodump&lt;/code&gt; to create a BSON backup that can later be restored.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Basic syntax:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;div &#xA;    x-data=&#34;{&#xA;        code: $el.querySelector(&#39;code&#39;).innerText&#xA;    }&#34;&#xA;    class=&#34;relative my-4 rounded-lg group&#34;&#xA;&gt;&#xA;    &lt;button&#xA;        @click=&#34;navigator.clipboard.writeText(code); $el.innerText = &#39;Copied!&#39;; setTimeout(() =&gt; $el.innerText = &#39;Copy&#39;, 2000)&#34;&#xA;        class=&#34;absolute top-2 right-2 bg-neutral-700 text-white text-xs px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition-opacity&#34;&#xA;    &gt;&#xA;        Copy&#xA;    &lt;/button&gt;&#xA;    &#xA;    &lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;mongodump -d &amp;lt;database_name&amp;gt; -o &amp;lt;backup_directory&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#xA;&lt;/div&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;code&gt;-d &amp;lt;database_name&amp;gt;&lt;/code&gt;&lt;/strong&gt; → the database to back up.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;code&gt;-o &amp;lt;backup_directory&amp;gt;&lt;/code&gt;&lt;/strong&gt; → the directory where the dump will be written.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Using MongoDB Aggregation to Build Hierarchical Category Structures</title>
      <link>https://nalar.dev/using-mongodb-aggregation-to-build-hierarchical-category-structures/</link>
      <pubDate>Tue, 05 Oct 2021 00:00:00 +0700</pubDate>
      <guid>https://nalar.dev/using-mongodb-aggregation-to-build-hierarchical-category-structures/</guid>
      <description>&lt;p&gt;Applications often need to represent hierarchical data such as parent categories, child categories, and deeper descendants. MongoDB&amp;rsquo;s aggregation framework includes &lt;code&gt;$graphLookup&lt;/code&gt;, which can recursively traverse relationships within a collection.&lt;/p&gt;&#xA;&lt;p&gt;This article shows how to use &lt;code&gt;$graphLookup&lt;/code&gt; to retrieve a category hierarchy from documents that reference their parent category.&lt;/p&gt;&#xA;&lt;h3 id=&#34;1-data-structure&#34;&gt;&lt;strong&gt;1. Data Structure&lt;/strong&gt;&lt;/h3&gt;&#xA;&lt;p&gt;Consider the following documents in a MongoDB collection:&lt;/p&gt;&#xA;&lt;div &#xA;    x-data=&#34;{&#xA;        code: $el.querySelector(&#39;code&#39;).innerText&#xA;    }&#34;&#xA;    class=&#34;relative my-4 rounded-lg group&#34;&#xA;&gt;&#xA;    &lt;button&#xA;        @click=&#34;navigator.clipboard.writeText(code); $el.innerText = &#39;Copied!&#39;; setTimeout(() =&gt; $el.innerText = &#39;Copy&#39;, 2000)&#34;&#xA;        class=&#34;absolute top-2 right-2 bg-neutral-700 text-white text-xs px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition-opacity&#34;&#xA;    &gt;&#xA;        Copy&#xA;    &lt;/button&gt;&#xA;    &#xA;    &lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-json&#34; data-lang=&#34;json&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;{ &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;cat_id&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;title&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Parent Category&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;parent&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#66d9ef&#34;&gt;null&lt;/span&gt; }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;{ &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;, &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;cat_id&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;, &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;title&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Child Category&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;parent&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt; }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;{ &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;_id&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#ae81ff&#34;&gt;3&lt;/span&gt;, &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;cat_id&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#ae81ff&#34;&gt;3&lt;/span&gt;, &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;title&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Sub Child Category&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;parent&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt; }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;The relationships are:&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to Create Users and Databases in MySQL</title>
      <link>https://nalar.dev/how-to-create-users-and-databases-in-mysql/</link>
      <pubDate>Wed, 08 Sep 2021 00:00:00 +0700</pubDate>
      <guid>https://nalar.dev/how-to-create-users-and-databases-in-mysql/</guid>
      <description>&lt;p&gt;Managing users and databases is a fundamental MySQL administration task. This guide shows how to create a user, create a database, and grant that user the permissions needed to work with the database.&lt;/p&gt;&#xA;&lt;h3 id=&#34;1-create-a-new-mysql-user&#34;&gt;&lt;strong&gt;1. Create a New MySQL User&lt;/strong&gt;&lt;/h3&gt;&#xA;&lt;p&gt;Start by creating a user with its own login credentials.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Basic syntax:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;div &#xA;    x-data=&#34;{&#xA;        code: $el.querySelector(&#39;code&#39;).innerText&#xA;    }&#34;&#xA;    class=&#34;relative my-4 rounded-lg group&#34;&#xA;&gt;&#xA;    &lt;button&#xA;        @click=&#34;navigator.clipboard.writeText(code); $el.innerText = &#39;Copied!&#39;; setTimeout(() =&gt; $el.innerText = &#39;Copy&#39;, 2000)&#34;&#xA;        class=&#34;absolute top-2 right-2 bg-neutral-700 text-white text-xs px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition-opacity&#34;&#xA;    &gt;&#xA;        Copy&#xA;    &lt;/button&gt;&#xA;    &#xA;    &lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sql&#34; data-lang=&#34;sql&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;CREATE&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;USER&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;user&amp;#39;&lt;/span&gt; IDENTIFIED &lt;span style=&#34;color:#66d9ef&#34;&gt;BY&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;password&amp;#39;&lt;/span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#xA;&lt;/div&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&#39;user&#39;&lt;/code&gt;: the username to create.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&#39;password&#39;&lt;/code&gt;: the password for that user.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
