Setting Up a MySQL Debugging Environment on Windows with VSCode and VMware
This article provides a step‑by‑step guide for Windows users to install VSCode, set up a VMware‑hosted CentOS 7 VM, compile the MySQL 8.0.34 source with debug options, configure VSCode remote‑debugging plugins, and perform source‑level debugging of MySQL.
Preface : Most developers use macOS for debugging, but as a DBA who prefers Windows, I needed a Windows‑based workflow to explore the MySQL source code. This article documents the process of building a MySQL debugging environment on Windows.
We will install VSCode on Windows 11, VMware Workstation 17 PRO, deploy a CentOS 7.5 VM, and use VSCode’s Remote‑SSH extension to debug a MySQL debug build inside the VM. Note that the Remote extension is installed on Windows, while the actual debugging extensions are installed inside the CentOS VM.
Environment and Software Preparation :
Win11
VMware WorkStation 17 PRO
CentOS 7.5 (running in VMware)
VSCode 1.81.1
MySQL 8.0.34 source package
All software versions are the latest at the time of writing.
CentOS 7 Environment Preparation : The default YUM repositories in CentOS 7 provide very old development packages, so we need epel-release to obtain newer debug dependencies.
# Create a directory for the source code
mkdir -p /root/code
# Enter the directory
cd /root/code
# Install wget, download and extract the source
yum install wget -y
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-boost-8.0.34.tar.gz
tar zxvf mysql-boost-8.0.34.tar.gz
# Install epel-release for newer packages
yum -y install epel-release
# Install newer gcc, make, etc.
yum -y install centos-release-scl
# Install required development tools
yum -y install devtoolset-11-gcc \
devtoolset-11-gcc-c++ \
devtoolset-11-make \
cmake3 \
openssl-devel \
ncurses-devel \
bison
# Install gdb
yum -y install devtoolset-11-gdb
# Enable the SCL environment temporarily
source /opt/rh/devtoolset-11/enable
# Make the SCL environment permanent
vi /etc/profile.d/scl.sh # add the line "source /opt/rh/devtoolset-11/enable" and saveCompile and Install MySQL Debug Version :
# config
cd /root/code/mysql-8.0.34
cmake3 . \
-DWITH_BOOST=./boost/ \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DWITH_DEBUG=1 \
-DFORCE_INSOURCE_BUILD=1
# build & install (using two parallel jobs because the VM has two CPUs)
make -j2 && make installAfter the build finishes, MySQL is installed under /usr/local/mysql . The following image shows the successful installation (image omitted).
Key CMake Parameters :
WITH_BOOST=./boost/ – points to the bundled Boost libraries.
CMAKE_INSTALL_PREFIX=/usr/local/mysql – installation base directory.
WITH_DEBUG=1 – builds a debuggable binary.
FORCE_INSOURCE_BUILD=1 – forces an in‑source build (not strictly required).
MySQL Initialization :
# Create configuration and data directories
mkdir -p /mysql/8.0.34/data # you can change this path
# Create mysql user and group
groupadd mysql
useradd -g mysql mysql
# Create my.cnf
vi /etc/my.cnf # paste the following content
[mysqld]
user=mysql
innodb_file_per_table=1
server_id=100
basedir=/usr/local/mysql
datadir=/mysql/8.0.34/data
log-error=/mysql/8.0.34/data/error.log
# Initialize the data directory (insecure mode)
/usr/local/mysql/bin/mysqld --initialize-insecureVSCode Plugin Installation :
6.1 Local Plugin Installation
Search the VSCode marketplace and install the following plugins: Chinese , Remote (which pulls in Remote‑SSH dependencies automatically).
6.2 Remote Plugin Installation
C/C++ (required for gdb debugging)
After installation, VSCode shows two panels: the upper panel lists plugins installed on the local Windows machine, and the lower panel lists plugins installed on the remote CentOS 7 VM.
Debugging :
7.1 Configure VSCode Debugger
cd /root/code/mysql-8.0.34
mkdir .vscode
cd .vscode
vi launch.jsonThe launch.json content:
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) launch",
"type": "cppdbg",
"request": "launch",
"program": "/usr/local/mysql/bin/mysqld",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{ "description": "Enable pretty printing", "text": "-enable-pretty-printing", "ignoreFailures": true },
{ "description": "Set disassembly flavor to Intel", "text": "-gdb-set disassembly-flavor intel", "ignoreFailures": true }
]
}
]
}7.2 Start gdb
(Image showing VSCode launching gdb – omitted.)
7.3 Connect to MySQL on CentOS
/usr/local/mysql/bin/mysql # login without password7.4 Set Breakpoint in VSCode
Open sql/sql_parse.cc in the MySQL source tree and set a breakpoint.
(Screenshots of the breakpoint UI omitted.)
7.5 Observe Breakpoint Effects
Run a simple query, e.g. SELECT host, user FROM mysql.user; . The program stops at the breakpoint, allowing you to inspect local variables, the call stack, and execute additional gdb commands via the VSCode debug console. When using the console, prepend commands with -exec , e.g. -exec p thd->m_query_string .
Summary : This guide adapts a Docker‑based MySQL debugging setup to a Windows environment by using VMware instead of Docker. The VM snapshot feature enables quick rollbacks, making the learning curve gentler for newcomers.
Further reading links and references are provided at the end of the original article.
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.