Skip to content

Update default datadir for debian to be /var/lib/mariadb#5059

Open
lvoytek wants to merge 7 commits into
MariaDB:mainfrom
lvoytek:set-new-default-datadir-debian
Open

Update default datadir for debian to be /var/lib/mariadb#5059
lvoytek wants to merge 7 commits into
MariaDB:mainfrom
lvoytek:set-new-default-datadir-debian

Conversation

@lvoytek

@lvoytek lvoytek commented May 8, 2026

Copy link
Copy Markdown

Match the existing datadir setting for Debian and Ubuntu, which was changed from /var/lib/mysql to /var/lib/mariadb in 1:11.8.6-5.

Existing Debian patch: https://salsa.debian.org/mariadb-team/mariadb-server/-/blob/debian/latest/debian/patches/set-default-datadir-to-var-lib-mariadb.patch

@CLAassistant

CLAassistant commented May 8, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the default data directory for Debian-based installations in cmake/install_layout.cmake by changing INSTALL_MYSQLDATADIR_DEB from /var/lib/mysql to /var/lib/mariadb. No review comments were provided for this change, and I have no feedback to provide.

@vuvova

vuvova commented May 8, 2026

Copy link
Copy Markdown
Member

Questions:

  • this is the main branch, so 13.0. A bit too late for Ubuntu?
  • what about upgrades 12.3→13.0 ? May be not a problem for Ubuntu, but the change affects our (vendor) packages too.
  • How does Ubuntu build MariaDB packages? You likely don't use our autobake.sh script, do you? In that case
    • we can set INSTALL_MYSQLDATADIR=/var/lib/mysql from our autobake.sh and keep the old path in vendor builds and the new path in Ubuntu builds
    • or Ubuntu can set INSTALL_MYSQLDATADIR=/var/lib/mariadb and get a new path without affecting vendor builds. I think the first approach might be easier.
    • or we can change all, Ubuntu and vendor, builds, and then pre/post-inst scriptlets need to handle the upgrade and move the data to the new location

@ottok, what do you think?

@vuvova vuvova requested review from ottok and vuvova May 8, 2026 21:08
@grooverdan

Copy link
Copy Markdown
Member

Thanks @lvoytek

Questions:

* this is the `main` branch, so 13.0. A bit too late for Ubuntu?

Ubuntu 26.04 already carrying the patch for 11.8_+
bugs.launchpad.net/ubuntu/+source/mariadb/+bug/2148632

* what about upgrades 12.3→13.0 ? May be not a problem for Ubuntu, but the change affects our (vendor) packages too.

I opened https://jira.mariadb.org/browse/MDEV-39461

But yes, we'll need the scripts too.

* How does Ubuntu build MariaDB packages? You likely don't use our `autobake.sh` script, do you? In that case

Like Debian - straight from debian/rules

  * we can set `INSTALL_MYSQLDATADIR=/var/lib/mysql` from our `autobake.sh` and keep the old path in vendor builds and the new path in Ubuntu builds
  * or Ubuntu can set `INSTALL_MYSQLDATADIR=/var/lib/mariadb` and get a new path without affecting vendor builds. I think the first approach might be easier.
  * or we can change all, Ubuntu and vendor, builds, and then pre/post-inst scriptlets need to handle the upgrade and move the data to the new location

I do like the last plan.

Question is, do we stop on Deb changes or include RPM too?

@ottok, what do you think?

Its already in Debian sid.

https://salsa.debian.org/mariadb-team/mariadb-server/-/merge_requests/155

I was hoping to see more of the script changes from that here.

Having a modified subset in 11.8 to handle Ubuntu upgrade to our vendor ones would be good too to solve MDEV-39461. Probably like a earlier version in salsa merge request 155 that dropped the config file in the post install without changing the default.

@gkodinov gkodinov added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label May 11, 2026

@gkodinov gkodinov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a preliminary review. Can you please describe the problem you're solving? I.e. what happens now and how is that wrong. And how your solution goes about solving the problem, i.e. how is the current behavior modified.
Ideally this should happen in an MDEV prior to submitting a PR for it, but I can also file one for you if you put your rationale into the PR itself.

@ottok

ottok commented May 11, 2026

Copy link
Copy Markdown
Contributor

If I am not mistaken, the submitter of this patch (Canonical employee) had some discussions with Sergei about switching the datadir to /var/lib/mariadb in MariaDB. This submission does that, and targets main to be in the next upstream MariaDB release.

This was already included in Debian and Ubuntu 1:11.6.8. The commit https://salsa.debian.org/mariadb-team/mariadb-server/-/commit/2bf6f4d3e1cb090ad5ba7f443ae02af5047c5391 in Debian is a bit more verbose than the commit message/description in this PR.

I approved this change in Debian with the assumption that upstream will eventually follow in some future version. This PR only updates the _DEB variable but you might as well also update the equivalent _RPM variable.

From my point of view this would be fine to merge as-is, and perhaps MariaDB devs can follow-up with whatever additional changes are needed to make /var/lib/mariadb the default datadir on all new (fresh) installations?

Upgrades of old installs will continue to use /var/lib/mysql, at least with how the package maintainer scripts are done in Debian/Ubuntu.

@vuvova

vuvova commented May 11, 2026

Copy link
Copy Markdown
Member

I like this 99-legacy-datadir.cnf technique, if we adopt that we can change the default indeed.

@lvoytek, your commit in Debian changes a lot more than this PR, are the other changes needed? Why did you omit them here?

@lvoytek

lvoytek commented May 15, 2026

Copy link
Copy Markdown
Author

I'm happy to include the packaging delta here too, I'll update the pr with it soon!

lvoytek added 7 commits May 26, 2026 10:05
Match the existing datadir setting for Debian and Ubuntu, which was
changed from /var/lib/mysql to /var/lib/mariadb in 1:11.8.6-5.
Check for MariaDB data in /var/lib/mariadb. If there is none, then
check in /var/lib/mysql instead. If the data there belongs to MariaDB,
then continue using it. If it belongs to MySQL, then ignore it and
handle the folder setup as a new install.
Likewise, stop using .flag files to determine version numbers. With the
guarantee that all mariadb installs will have an upgrade info file in
the data directory, it is no longer necessary to determine the
version from the .flag file. Update detection logic to reflect this,
and clear remaining flag file logic other than flag file removal.
…iadb

MySQL log files and the mysql user will be removed if mariadb owns them.
The log files should be split eventually though.
Update logic for handling the new /var/lib/mariadb datadir. For legacy
installs, drop in an additional file, 99-legacy-datadir.cnf, that
overrides the value back to /var/lib/mysql. Also remove this new file
on purge. Mention the default change in 50-server.cnf. Finally,
set the default datadir in mariadb-server mariadb.init to
/var/lib/mariadb.
list of /var/lib/mariadb files as test artifact
@lvoytek lvoytek force-pushed the set-new-default-datadir-debian branch from c1c3f3c to 6367619 Compare May 26, 2026 14:43
@lvoytek

lvoytek commented May 26, 2026

Copy link
Copy Markdown
Author

Sorry for the delay, all relevant changes for the datadir update should now be here

@ottok ottok left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed and approved the original changes in Debian/Ubuntu, and I support having these upstreamed to MariaDB 'main' to be in effect in the next upstream release.

Hopefully someone can holistically review the MariaDB packaging after this is merged and add RPM changes and whatever is needed so that upstream can announce /var/lib/mariadb as the new datadir location in the next new version release.

CI is failing on two jobs. They should be checked before merging this. Unfortunately latest commit on 'main' is also failing, so I guess contributors to MariaDB shouldn't expect their PRs to pass CI either, but still good to take a look if there is something relevant looking.

(Upstream is not using Salsa CI, so the Salsa CI update is moot and the rest of the Salsa CI won't be passing anyway, but having this commit won't make anything worse either.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.

Development

Successfully merging this pull request may close these issues.

6 participants