bilalsonija

bilalsonija

ผู้เยี่ยมชม

bilalsonija2@gmail.com

  bilal (85 อ่าน)

21 มิ.ย. 2568 04:47

<h1 data-start="84" data-end="139">How to Install MariaDB on Debian 12: A Complete Guide</h1>
<p data-start="141" data-end="435">MariaDB is a popular, open-source relational database management system that is widely used as a drop-in replacement for MySQL. It is known for its speed, reliability, and active development community. In this tutorial, we will guide you step-by-step on how to install MariaDB on Debian 12.

<hr data-start="437" data-end="440" />
<h2 data-start="442" data-end="458">Prerequisites</h2>
<p data-start="459" data-end="493">Before you begin, ensure you have:

<ul data-start="494" data-end="604">
<li data-start="494" data-end="537">
<p data-start="496" data-end="537">A system running <strong data-start="513" data-end="537">Debian 12 (Bookworm)

</li>
<li data-start="538" data-end="577">
<p data-start="540" data-end="577">A user account with <code data-start="560" data-end="566">sudo</code> privileges

</li>
<li data-start="578" data-end="604">
<p data-start="580" data-end="604">Basic terminal knowledge

</li>
</ul>
<hr data-start="606" data-end="609" />
<h2 data-start="611" data-end="644">Step 1: Update System Packages</h2>
<p data-start="645" data-end="739">Start by updating your system&rsquo;s package index to ensure all available packages are up to date.

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary">
<div class="flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between h-9 bg-token-sidebar-surface-primary select-none rounded-t-2xl">bash</div>
<div class="sticky top-9">
<div class="absolute end-0 bottom-0 flex h-9 items-center pe-2">
<div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><button class="flex gap-1 items-center select-none py-1">Copy</button><span class="" data-state="closed"><button class="flex items-center gap-1 py-1 select-none">Edit</button></span></div>
</div>
</div>
<div class="overflow-y-auto p-4" dir="ltr"><code class="whitespace-pre! language-bash">sudo apt update && sudo apt upgrade -y
</code></div>
</div>
<hr data-start="793" data-end="796" />
<h2 data-start="798" data-end="831">Step 2: Install MariaDB Server</h2>
<p data-start="832" data-end="935">MariaDB is included in the default Debian repositories. You can install it using the following command:

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary">
<div class="flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between h-9 bg-token-sidebar-surface-primary select-none rounded-t-2xl"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">bash</span></span></div>
<div class="sticky top-9">
<div class="absolute end-0 bottom-0 flex h-9 items-center pe-2">
<div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><button class="flex gap-1 items-center select-none py-1"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">Copy</span></span></button><span class="" data-state="closed"><button class="flex items-center gap-1 py-1 select-none"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">Edit</span></span></button></span></div>
</div>
</div>
<div class="overflow-y-auto p-4" dir="ltr"><code class="whitespace-pre! language-bash">sudo apt install mariadb-server -y
</code></div>
</div>
<hr data-start="985" data-end="988" />
<h2 data-start="990" data-end="1033">Step 3: Start and Enable MariaDB Service</h2>
<p data-start="1034" data-end="1121">Once installed, start the MariaDB service and enable it to automatically start on boot.

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary">
<div class="flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between h-9 bg-token-sidebar-surface-primary select-none rounded-t-2xl"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">bash</span></span></div>
<div class="sticky top-9">
<div class="absolute end-0 bottom-0 flex h-9 items-center pe-2">
<div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><button class="flex gap-1 items-center select-none py-1"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">Copy</span></span></button><span class="" data-state="closed"><button class="flex items-center gap-1 py-1 select-none"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">Edit</span></span></button></span></div>
</div>
</div>
<div class="overflow-y-auto p-4" dir="ltr"><code class="whitespace-pre! language-bash">sudo systemctl start mariadb
sudo systemctl <span class="hljs-built_in">enable</span> mariadb
</code></div>
</div>
<p data-start="1195" data-end="1257">You can verify that MariaDB is running by checking its status:

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary">
<div class="flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between h-9 bg-token-sidebar-surface-primary select-none rounded-t-2xl"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">bash</span></span></div>
<div class="sticky top-9">
<div class="absolute end-0 bottom-0 flex h-9 items-center pe-2">
<div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><button class="flex gap-1 items-center select-none py-1"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">Copy</span></span></button><span class="" data-state="closed"><button class="flex items-center gap-1 py-1 select-none"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">Edit</span></span></button></span></div>
</div>
</div>
<div class="overflow-y-auto p-4" dir="ltr"><code class="whitespace-pre! language-bash">sudo systemctl status mariadb
</code></div>
</div>
<hr data-start="1302" data-end="1305" />
<h2 data-start="1307" data-end="1345">Step 4: Secure MariaDB Installation</h2>
<p data-start="1346" data-end="1440">MariaDB comes with a security script that helps you improve the security of your installation.

<p data-start="1442" data-end="1468">Run the following command:

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary">
<div class="flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between h-9 bg-token-sidebar-surface-primary select-none rounded-t-2xl">bash</div>
<div class="sticky top-9">
<div class="absolute end-0 bottom-0 flex h-9 items-center pe-2">
<div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><button class="flex gap-1 items-center select-none py-1">Copy</button><span class="" data-state="closed"><button class="flex items-center gap-1 py-1 select-none">Edit</button></span></div>
</div>
</div>
<div class="overflow-y-auto p-4" dir="ltr"><code class="whitespace-pre! language-bash">sudo mysql_secure_installation
</code></div>
</div>
<p data-start="1514" data-end="1544">The script will prompt you to:

<ul data-start="1545" data-end="1728">
<li data-start="1545" data-end="1624">
<p data-start="1547" data-end="1624">Set a root password (optional in Debian, as root login via socket is default)

</li>
<li data-start="1625" data-end="1649">
<p data-start="1627" data-end="1649">Remove anonymous users

</li>
<li data-start="1650" data-end="1678">
<p data-start="1652" data-end="1678">Disallow remote root login

</li>
<li data-start="1679" data-end="1702">
<p data-start="1681" data-end="1702">Remove test databases

</li>
<li data-start="1703" data-end="1728">
<p data-start="1705" data-end="1728">Reload privilege tables

</li>
</ul>
<p data-start="1730" data-end="1823">For most cases, you can safely answer <code data-start="1768" data-end="1771">Y</code> to all prompts to secure your MariaDB installation.

<hr data-start="1825" data-end="1828" />
<h2 data-start="1830" data-end="1868">Step 5: Verify MariaDB Installation</h2>
<p data-start="1869" data-end="1948">Log in to the MariaDB shell to confirm the database server is working properly.

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary">
<div class="flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between h-9 bg-token-sidebar-surface-primary select-none rounded-t-2xl"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">bash</span></span></div>
<div class="sticky top-9">
<div class="absolute end-0 bottom-0 flex h-9 items-center pe-2">
<div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><button class="flex gap-1 items-center select-none py-1"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">Copy</span></span></button><span class="" data-state="closed"><button class="flex items-center gap-1 py-1 select-none"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">Edit</span></span></button></span></div>
</div>
</div>
<div class="overflow-y-auto p-4" dir="ltr"><code class="whitespace-pre! language-bash">sudo mariadb
</code></div>
</div>
<p data-start="1976" data-end="2010">You should see the MariaDB prompt:

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary">
<div class="flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between h-9 bg-token-sidebar-surface-primary select-none rounded-t-2xl">text</div>
<div class="sticky top-9">
<div class="absolute end-0 bottom-0 flex h-9 items-center pe-2">
<div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><button class="flex gap-1 items-center select-none py-1"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">Copy</span></span></button><span class="" data-state="closed"><button class="flex items-center gap-1 py-1 select-none"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">Edit</span></span></button></span></div>
</div>
</div>
<div class="overflow-y-auto p-4" dir="ltr"><code class="whitespace-pre! language-text">Welcome to the MariaDB monitor. Commands end with ; or \g.
MariaDB [(none)]>
</code></div>
</div>
<p data-start="2101" data-end="2140">Type <code data-start="2106" data-end="2112">exit</code> to leave the MariaDB shell.

<hr data-start="2142" data-end="2145" />
<h2 data-start="2147" data-end="2193">Step 6: Allow Remote Connections (Optional)</h2>
<p data-start="2194" data-end="2278">By default, MariaDB only listens on <code data-start="2230" data-end="2241">localhost</code>. If you want to allow remote access:

<ol data-start="2279" data-end="2586">
<li data-start="2279" data-end="2389">
<p data-start="2282" data-end="2318">Open the MariaDB configuration file:

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary">
<div class="flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between h-9 bg-token-sidebar-surface-primary select-none rounded-t-2xl"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">bash</span></span></div>
<div class="sticky top-9">
<div class="absolute end-0 bottom-0 flex h-9 items-center pe-2">
<div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><button class="flex gap-1 items-center select-none py-1"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">Copy</span></span></button><span class="" data-state="closed"><button class="flex items-center gap-1 py-1 select-none"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">Edit</span></span></button></span></div>
</div>
</div>
<div class="overflow-y-auto p-4" dir="ltr"><code class="whitespace-pre! language-bash">sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
</code></div>
</div>
</li>
<li data-start="2390" data-end="2453">
<p data-start="2393" data-end="2407">Find the line:

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary">
<div class="flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between h-9 bg-token-sidebar-surface-primary select-none rounded-t-2xl"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">bash</span></span></div>
<div class="sticky top-9">
<div class="absolute end-0 bottom-0 flex h-9 items-center pe-2">
<div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><button class="flex gap-1 items-center select-none py-1"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">Copy</span></span></button><span class="" data-state="closed"><button class="flex items-center gap-1 py-1 select-none"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">Edit</span></span></button></span></div>
</div>
</div>
<div class="overflow-y-auto p-4" dir="ltr"><code class="whitespace-pre! language-bash">bind-address = 127.0.0.1
</code></div>
</div>
</li>
<li data-start="2454" data-end="2514">
<p data-start="2457" data-end="2470">Change it to:

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary">
<div class="flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between h-9 bg-token-sidebar-surface-primary select-none rounded-t-2xl"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">bash</span></span></div>
<div class="sticky top-9">
<div class="absolute end-0 bottom-0 flex h-9 items-center pe-2">
<div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><button class="flex gap-1 items-center select-none py-1"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">Copy</span></span></button><span class="" data-state="closed"><button class="flex items-center gap-1 py-1 select-none"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">Edit</span></span></button></span></div>
</div>
</div>
<div class="overflow-y-auto p-4" dir="ltr"><code class="whitespace-pre! language-bash">bind-address = 0.0.0.0
</code></div>
</div>
</li>
<li data-start="2515" data-end="2586">
<p data-start="2518" data-end="2534">Restart MariaDB:

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary">
<div class="flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between h-9 bg-token-sidebar-surface-primary select-none rounded-t-2xl"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">bash</span></span></div>
<div class="sticky top-9">
<div class="absolute end-0 bottom-0 flex h-9 items-center pe-2">
<div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><button class="flex gap-1 items-center select-none py-1"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">Copy</span></span></button><span class="" data-state="closed"><button class="flex items-center gap-1 py-1 select-none"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">Edit</span></span></button></span></div>
</div>
</div>
<div class="overflow-y-auto p-4" dir="ltr"><code class="whitespace-pre! language-bash">sudo systemctl restart mariadb
</code></div>
</div>
</li>
</ol>
<p data-start="2588" data-end="2671"><strong data-start="2588" data-end="2597">Note: Ensure your firewall allows connections to MariaDB&rsquo;s default port (3306).

<hr data-start="2673" data-end="2676" />
<h2 data-start="2678" data-end="2722">Step 7: Basic MariaDB Management Commands</h2>
<p data-start="2723" data-end="2780">Here are some useful MariaDB service management commands:



<ul data-start="2781" data-end="2982">
<li data-start="2781" data-end="2848">
<p data-start="2783" data-end="2799"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">Restart MariaDB:</span></span>

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary">
<div class="flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between h-9 bg-token-sidebar-surface-primary select-none rounded-t-2xl"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">bash</span></span></div>
<div class="sticky top-9">
<div class="absolute end-0 bottom-0 flex h-9 items-center pe-2">
<div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><button class="flex gap-1 items-center select-none py-1"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">Copy</span></span></button><span class="" data-state="closed"><button class="flex items-center gap-1 py-1 select-none"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">Edit</span></span></button></span></div>
</div>
</div>
<div class="overflow-y-auto p-4" dir="ltr"><code class="whitespace-pre! language-bash">sudo systemctl restart mariadb
</code></div>
</div>
</li>
<li data-start="2849" data-end="2910">
<p data-start="2851" data-end="2864">Stop MariaDB:

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary">
<div class="flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between h-9 bg-token-sidebar-surface-primary select-none rounded-t-2xl"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">bash</span></span></div>
<div class="sticky top-9">
<div class="absolute end-0 bottom-0 flex h-9 items-center pe-2">
<div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><button class="flex gap-1 items-center select-none py-1"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">Copy</span></span></button><span class="" data-state="closed"><button class="flex items-center gap-1 py-1 select-none"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">Edit</span></span></button></span></div>
</div>
</div>
<div class="overflow-y-auto p-4" dir="ltr"><code class="whitespace-pre! language-bash">sudo systemctl stop mariadb
</code></div>
</div>
</li>
<li data-start="2911" data-end="2982">
<p data-start="2913" data-end="2934">Check MariaDB status:

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary">
<div class="flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between h-9 bg-token-sidebar-surface-primary select-none rounded-t-2xl"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">bash</span></span></div>
<div class="sticky top-9">
<div class="absolute end-0 bottom-0 flex h-9 items-center pe-2">
<div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><button class="flex gap-1 items-center select-none py-1"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">Copy</span></span></button><span class="" data-state="closed"><button class="flex items-center gap-1 py-1 select-none"><span style="vertical-align: inherit;"><span style="vertical-align: inherit;">Edit</span></span></button></span></div>
</div>
</div>
<div class="overflow-y-auto p-4" dir="ltr"><code class="whitespace-pre! language-bash">sudo systemctl status mariadb</code></div>
</div>
</li>
</ul>

103.74.20.198

bilalsonija

bilalsonija

ผู้เยี่ยมชม

bilalsonija2@gmail.com

ตอบกระทู้
Powered by MakeWebEasy.com
เว็บไซต์นี้มีการใช้งานคุกกี้ เพื่อเพิ่มประสิทธิภาพและประสบการณ์ที่ดีในการใช้งานเว็บไซต์ของท่าน ท่านสามารถอ่านรายละเอียดเพิ่มเติมได้ที่ นโยบายความเป็นส่วนตัว  และ  นโยบายคุกกี้