<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MariaDB - Matteo Cisilino</title>
	<atom:link href="https://www.cisilino.com/en/tag/mariadb-en/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.cisilino.com/en/</link>
	<description>Guide su WordPress, server e sicurezza</description>
	<lastBuildDate>Thu, 29 Oct 2026 19:00:32 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.4</generator>
	<item>
		<title>MySQL won&#8217;t start after a Debian 12 upgrade: cause and fix</title>
		<link>https://www.cisilino.com/en/2026/10/13/mysql-wont-start-debian-12/</link>
					<comments>https://www.cisilino.com/en/2026/10/13/mysql-wont-start-debian-12/#respond</comments>
		
		<dc:creator><![CDATA[matteocisilino]]></dc:creator>
		<pubDate>Tue, 13 Oct 2026 07:50:06 +0000</pubDate>
				<category><![CDATA[Servers and databases]]></category>
		<category><![CDATA[Debian 12]]></category>
		<category><![CDATA[MariaDB]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[upgrade]]></category>
		<guid isPermaLink="false">https://www.cisilino.com/?p=255</guid>

					<description><![CDATA[<p>After a Debian 12 upgrade MySQL won't start and the logs mention mariadb.conf.d. How to identify the cause and fix it without touching your data.</p>
<p>The post <a href="https://www.cisilino.com/en/2026/10/13/mysql-wont-start-debian-12/">MySQL won’t start after a Debian 12 upgrade: cause and fix</a> first appeared on <a href="https://www.cisilino.com/en/">Matteo Cisilino</a>.</p>]]></description>
										<content:encoded><![CDATA[<h2 class="wp-block-heading">The symptom: mysql.service in a failed state</h2>
<p>MySQL won&#8217;t start: the service shows as failed and the log reports the error <code>Can't read dir of '/etc/mysql/mariadb.conf.d/'</code>:</p>
<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" src="https://www.cisilino.com/wp-content/uploads/2026/10/mysql-wont-start-debian-12-upgrade.webp" alt="MySQL won't start: a cylinder representing a database with an orange warning circle beside it" width="1200" height="630"/></figure>
<pre class="wp-block-code"><code># service mysql status
× mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; preset: enabled)
     Active: failed (Result: exit-code)
     Status: "Server startup in progress"

mysqld: Can't read dir of '/etc/mysql/mariadb.conf.d/' (OS errno 2 - No such file or directory)
mysqld: &#91;ERROR] Stopped processing the 'includedir' directive in file /etc/mysql/my.cnf at line 29.
mysqld: &#91;ERROR] Fatal error in defaults handling. Program aborted!
systemd&#91;1]: Failed to start mysql.service - MySQL Community Server.</code></pre>
<p>Checking the installed packages, MySQL is there as expected (<code>mysql-community-server</code> 8.0 packages from the official Oracle repository):</p>
<pre class="wp-block-code"><code>dpkg -l | grep mysql</code></pre>
<h2 class="wp-block-heading">The cause: the my.cnf alternative points to mariadb.cnf</h2>
<p>On Debian the file <code>/etc/mysql/my.cnf</code> is not a real file but a link managed by <strong>update-alternatives</strong>. Several packages can register their own version and, in automatic mode, the one with the highest priority wins.</p>
<p>During the upgrade the <strong>mariadb-common</strong> package was installed (and later removed), which registers <code>/etc/mysql/mariadb.cnf</code> with <strong>priority 500</strong>, higher than <code>/etc/mysql/mysql.cnf</code> (priority 300). The package was removed but not fully purged (state <code>rc</code>), so its configuration stayed active. On line 29 of that file there is an include of <code>/etc/mysql/mariadb.conf.d/</code>, a directory that does not exist. MySQL reads the configuration, cannot find the directory and stops, which is why MySQL won&#8217;t start.</p>
<p><strong>Good news:</strong> the data in <code>/var/lib/mysql</code> has not been touched. It is only a configuration problem.</p>
<h2 class="wp-block-heading">Diagnosis: check where my.cnf points</h2>
<pre class="wp-block-code"><code>ls -l /etc/mysql/my.cnf /etc/alternatives/my.cnf
update-alternatives --display my.cnf
sed -n '25,32p' /etc/mysql/my.cnf
dpkg -l | grep -i mariadb</code></pre>
<p>If this is the problem, the output will look like this:</p>
<pre class="wp-block-code"><code>/etc/alternatives/my.cnf -&gt; /etc/mysql/mariadb.cnf
/etc/mysql/my.cnf -&gt; /etc/alternatives/my.cnf

my.cnf - modalità automatica
  la versione migliore del collegamento è /etc/mysql/mariadb.cnf
  il collegamento attualmente punta a /etc/mysql/mariadb.cnf
/etc/mysql/mariadb.cnf - priorità 500
/etc/mysql/my.cnf.fallback - priorità 100
/etc/mysql/mysql.cnf - priorità 300

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mariadb.conf.d/

rc  mariadb-common   1:10.11.18-0+deb12u1   all   MariaDB common configuration files</code></pre>
<h2 class="wp-block-heading">Step-by-step fix</h2>
<h3 class="wp-block-heading">1. Back up the configuration</h3>
<pre class="wp-block-code"><code>cp -a /etc/mysql /root/etc-mysql-backup-$(date +%F)</code></pre>
<h3 class="wp-block-heading">2. Remove the mariadb-common leftovers</h3>
<p>The purge removes <code>mariadb.cnf</code> and its entry in update-alternatives:</p>
<pre class="wp-block-code"><code>apt purge mariadb-common</code></pre>
<h3 class="wp-block-heading">3. Point my.cnf back to mysql.cnf</h3>
<pre class="wp-block-code"><code>update-alternatives --remove my.cnf /etc/mysql/mariadb.cnf 2&gt;/dev/null
update-alternatives --set my.cnf /etc/mysql/mysql.cnf</code></pre>
<h3 class="wp-block-heading">4. Check the configuration</h3>
<pre class="wp-block-code"><code>update-alternatives --display my.cnf
cat /etc/mysql/my.cnf
my_print_defaults mysqld</code></pre>
<p>Now <code>my.cnf</code> must point to <code>/etc/mysql/mysql.cnf</code> and include <code>/etc/mysql/conf.d/</code> and <code>/etc/mysql/mysql.conf.d/</code>. If <code>my_print_defaults mysqld</code> prints the parameters without errors, the configuration is correct.</p>
<h3 class="wp-block-heading">5. Start MySQL</h3>
<pre class="wp-block-code"><code>systemctl start mysql
systemctl status mysql
journalctl -u mysql -n 50 --no-pager</code></pre>
<h2 class="wp-block-heading">If MySQL won&#8217;t start and my.cnf is not a symbolic link</h2>
<p>If <code>/etc/mysql/my.cnf</code> is a regular file or <code>/etc/mysql/mysql.cnf</code> does not exist, you can recreate the configuration by hand:</p>
<pre class="wp-block-code"><code>mv /etc/mysql/my.cnf /etc/mysql/my.cnf.mariadb.bak
cat &gt; /etc/mysql/my.cnf &lt;&lt;'EOF'
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
EOF
mkdir -p /etc/mysql/conf.d
systemctl start mysql</code></pre>
<h2 class="wp-block-heading">Quick temporary fix when MySQL won&#8217;t start</h2>
<p>If you need to bring the database back online right away, just create the missing directory. It is only a stopgap, though. MySQL would keep reading the configuration meant for MariaDB. Better to apply the complete fix as soon as possible.</p>
<pre class="wp-block-code"><code>mkdir /etc/mysql/mariadb.conf.d &amp;&amp; systemctl start mysql</code></pre>
<h2 class="wp-block-heading">How to stop it happening again</h2>
<p>It is worth finding out which upgrade installed MariaDB, by looking at the apt history:</p>
<pre class="wp-block-code"><code>grep -i -B3 -A3 mariadb /var/log/apt/history.log*</code></pre>
<p>To stop <code>mariadb-common</code> being reinstalled in the future you can block it with an APT pin at a negative priority:</p>
<pre class="wp-block-code"><code>cat &gt; /etc/apt/preferences.d/no-mariadb &lt;&lt;'EOF'
Package: mariadb-*
Pin: release *
Pin-Priority: -1
EOF</code></pre>
<p>After every major upgrade it is also good practice to check the state of the alternative with <code>update-alternatives --display my.cnf</code>. Before the next upgrade, read the <a href="https://www.debian.org/releases/bookworm/amd64/release-notes/" target="_blank" rel="noopener">Debian 12 release notes</a> for known issues. A related case is <a href="https://www.cisilino.com/en/2026/10/17/mysql-5-7-docker-nftables-firewall/">MySQL 5.7 in Docker protected with nftables</a>.</p>
<h2 class="wp-block-heading">Frequently asked questions</h2>
<h3 class="wp-block-heading">Will I lose my database data?</h3>
<p>No. The problem only concerns the configuration files in <code>/etc/mysql</code>; the data in <code>/var/lib/mysql</code> stays intact.</p>
<h3 class="wp-block-heading">Why did Debian choose mariadb.cnf?</h3>
<p>Because the <code>my.cnf</code> alternative was in automatic mode and <code>mariadb.cnf</code> has priority 500, higher than the 300 of <code>mysql.cnf</code>. With <code>update-alternatives --set</code> the choice becomes manual and no longer changes by itself.</p>
<h3 class="wp-block-heading">Does it apply to Ubuntu too?</h3>
<p>Yes, the <code>update-alternatives</code> mechanism for <code>my.cnf</code> is the same on Ubuntu and on the other Debian-derived distributions.</p>
<h2 class="wp-block-heading">Conclusion</h2>
<p>The error <strong>&#8220;Can&#8217;t read dir of /etc/mysql/mariadb.conf.d/&#8221;</strong> after a Debian upgrade does not mean MySQL is damaged. It means a leftover MariaDB configuration has stayed active through update-alternatives. By removing <code>mariadb-common</code> with <code>apt purge</code> and setting <code>my.cnf</code> back to <code>mysql.cnf</code>, MySQL works normally again. If MySQL won&#8217;t start after an upgrade, check update-alternatives first.</p></p><p>The post <a href="https://www.cisilino.com/en/2026/10/13/mysql-wont-start-debian-12/">MySQL won’t start after a Debian 12 upgrade: cause and fix</a> first appeared on <a href="https://www.cisilino.com/en/">Matteo Cisilino</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://www.cisilino.com/en/2026/10/13/mysql-wont-start-debian-12/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
