How to Compile a Debug Version of MySQL Using Docker
This article explains step‑by‑step how to build a MySQL debug binary inside a Docker container, covering environment preparation, dependency installation, configuring the build with CMake, compiling, and locating the resulting mysqld‑debug executable, while also noting performance trade‑offs of debug builds.
In this tutorial we show how to compile a debug version of MySQL when the official mysqld‑debug binary is unavailable.
First, prepare a Docker environment with a devtoolset image so the build can be performed in an isolated, reproducible container.
Enter the container, verify the shell, then download and extract the MySQL source package.
Install the required dependencies, which are divided into three groups: build tools, MySQL runtime libraries, and DTRACE‑related packages (the latter will be covered later).
Create a build directory where all compilation artifacts will be placed.
Run the CMake configuration command with appropriate flags (including -DWITH_DEBUG=1 ) and confirm that the output ends with a successful configuration message.
Start the compilation; after a lengthy output the build finishes successfully and the debug binary mysqld appears in build/sql .
A tip: to build an official release version, replace -DWITH_DEBUG=1 with -DBUILD_CONFIG=mysql_release in the CMake command.
Why use a debug build? Debug binaries retain symbol information that is stripped in optimized releases, allowing developers to attach debuggers (e.g., gdb) and investigate MySQL internals, though they run slower and are not suitable for performance testing.
Aikesheng Open Source Community
The Aikesheng Open Source Community provides stable, enterprise‑grade MySQL open‑source tools and services, releases a premium open‑source component each year (1024), and continuously operates and maintains them.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.