I need to programmatically call mysqldump with certain parameters. I try to use either the --source-data option or the --master-data option.

There is the following phrase in the documentation:

From MySQL 8.0.26, use --source-data, and before MySQL 8.0.26, use --master-data

In order to use the correct parameter, I need to determine the version of the MySQL client. But here I face an issue. I ran the mysqldump --version command on different servers and found that the version is not formalized, and is output in different formats on different servers.

On one server, I got the following result:

mysqldump Ver 8.0.28-0ubuntu0.20.04.3 for Linux on x86_64 ((Ubuntu))

And the following on the other server:

mysqldump Ver 10.13 Distrib 5.7.37, for Linux (x86_64)

The format is obviously different. In this case, the version is in different positions. On the first server version is 8.0.28, on the other, it is 5.7.37. Perhaps there are other formats? How do I get the version of the client simply in the major.minor.path format?

It seems that the regular expression \d*\.\d*\.\d* is an appropriate option. But on other hand, it seems like an unreliable solution, since there may be more formats for how to output the MySQL client version.

  • 2
    Execute mysqldump --help and search for '--source-data' substring. Use it if found and '--master-data' if not.
    – Akina
    Commented Mar 14, 2022 at 16:36
  • Ha, thanks, this is a cool workaround
    – Ivan
    Commented Mar 14, 2022 at 17:28
  • 1
    Write a bug report about their failure to accept "master" (with a "deprecation" warning) until at least the next major version.
    – Rick James
    Commented Mar 14, 2022 at 17:52

1 Answer 1


I found three options for how to get the version.

In Linux

You can find out the version of the installed mysql-client package:

sudo apt show mysql-client | grep Version

Version: 8.0.29-0ubuntu0.20.04.3

Here the version format is the same for everyone.

The version can be extracted by one line:

sudo apt show mysql-client | grep Version | sed 's/Version: //' | sed 's/-.*//'

In Windows

The easiest way is to take the version of the mysql.exe file itself:

enter image description here

more details on how to do it programmatically (c#):



You can simply find out if the command is supported by a given version of the client by executing mysql --help and check if the desired parameter in output text.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.