Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install matching mysql/mysqldump/mariadb-dump client inside ddev-webserver based on mysql or mariadb database type #6083

Open
rfay opened this issue Apr 11, 2024 · 9 comments
Milestone

Comments

@rfay
Copy link
Member

rfay commented Apr 11, 2024

In general, the mysql client shipped with the ddev-webserver works fine with all mariadb and mysql back-end databases.

However, there are a few cases where their behavior is slightly different.

And the fact that the mysql client reports a different version is often confusing to people.

For example, with database mysql:8.0 we see these outputs:

rfay@rfay-mbp-2021:~/workspace/d10$ ddev exec mysql --version
mysql  Ver 15.1 Distrib 10.11.6-MariaDB, for debian-linux-gnu (aarch64) using  EditLine wrapper

rfay@rfay-mbp-2021:~/workspace/d10$ ddev exec -s db mysql --version
mysql  Ver 8.0.33-0ubuntu0.20.04.2 for Linux on aarch64 ((Ubuntu))

The web container has the mariadb version, and the db container has the mysql:8.0 version.

On Craft CMS and perhaps some other places, people have the habit of using the built-in tools; Craft actually calls out to the mysql client (on ddev-webserver) rather than connecting directly to the database server, so this can cause confusion there.

Proposal

Add a layer to the ddev-webserver adding a matching mysql client to the ddev-webserver, especially where the database type is mysql:8.0, which is the most likely place for concern.

It also might be possible to implement this as an add-on for the few people it matters to. It's tricky getting the proper match between the OS-provided mysql client and the ddev-webserver, and it could introduce instabilities.

@rfay rfay changed the title Install matching mysql client inside ddev-webserver based on mysql or mariadb database type Install matching mysql/mysqldump client inside ddev-webserver based on mysql or mariadb database type Apr 11, 2024
@stasadev
Copy link
Member

stasadev commented Apr 30, 2024

Answering to #6139 (comment) in the relevant issue:

Is there something like that where we can get the mysql version of the client also?

There is mysql-apt-config https://dev.mysql.com/doc/refman/8.4/en/linux-installation-apt-repo.html

The current latest version is 0.8.30 https://dev.mysql.com/get/mysql-apt-config_0.8.30-1_all.deb

How to install mysql-server in non-interactive way https://stackoverflow.com/a/37267411/8097891

The SO example needs to be modified to change the server to client, but I think it's an achievable goal.

@rfay
Copy link
Member Author

rfay commented Apr 30, 2024

I'm not sure there's a client package, but if there is this can be great!

@rfay rfay changed the title Install matching mysql/mysqldump client inside ddev-webserver based on mysql or mariadb database type Install matching mysql/mysqldump/mariadb-dump client inside ddev-webserver based on mysql or mariadb database type May 17, 2024
@rfay
Copy link
Member Author

rfay commented May 17, 2024

Now that MariaDB has released mariadb-dump/mysqldump versions that are completely incompatible with "traditional" versions, we're going to have to prioritize this.

From: https://mariadb.com/kb/en/mariadb-dump/

Note: From MariaDB 10.5.25, MariaDB 10.6.18, MariaDB 10.11.8, MariaDB 11.0.6, MariaDB 11.1.5, MariaDB 11.2.4 and MariaDB 11.4.2 mariadb-dump generates a command at the beginning of the dump to enable sandbox mode. This command cannot be interpreted by earlier versions of the MariaDB command line client or by MySQL's command line client, and the client will generate an error if used against the versions that do not support it. This does not affect other methods of importing the data.

Basically, all the latest supported patch versions of mysqldump from mariadb are completely incompatible (without workarounds) with the previous patch version. So mariadb-dump/mysqldump 10.6.18's version is incompatible with 10.6.17. What's up with them!!!

Unfortunately, there isn't much we can do about it. This change came as a fix for CVE-2024-21096, and security fixes can sometimes break backward compatibility.

In this particular case, though, there are plenty of workarounds:

  • you can use the new mariadb client to restore the backup on the old MariaDB/MySQL server
  • you can use old mariadb-dump to make a backup of the new MariaDB server
  • you can use mariadb-dump|tail +2 to remove the problematic line when making a backup
  • you can use tail +2|mariadb to remove the problematic line when applying a backup

@rfay rfay added this to the v1.23.2 milestone May 17, 2024
@manutepowa
Copy link

Indeed mariadb has added sandbox mode, and database backups fail.
https://jira.mariadb.org/browse/MDEV-34183

@rfay
Copy link
Member Author

rfay commented May 18, 2024

MariaDB Blog about the change to dump file format: https://mariadb.org/mariadb-dump-file-compatibility-change/

@cristiroma
Copy link

cristiroma commented May 22, 2024

FYIW - We are mitigating with the following commands on the web container:

docker exec -ti ddev-PROJECT-web bash
sudo apt remove mariadb-client -y
sudo curl -LsS https://r.mariadb.com/downloads/mariadb_repo_setup | sudo bash -s -- --mariadb-server-version="mariadb-10.11"
sudo apt install mariadb-client -y

@rfay
Copy link
Member Author

rfay commented May 22, 2024

Thanks @cristiroma - It would be a lot better as a .ddev/web-build/Dockerfile.mariaclient or something, you wouldn't have to do it all the time.

@v11ncent
Copy link

v11ncent commented May 24, 2024

I was able to import a file dumped with the new mariadb-dump by deleting the line at the top of the dump that says /*!999999\- enable the sandbox mode */ in my MariaDB dump file.

@rfay
Copy link
Member Author

rfay commented May 27, 2024

The affected DDEV database images have been pushed with updated mariadb tools, please see

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants