ask

We have used mysqld-debug, the built-in debug version of mysql in Question 16, but some MySQL versions do not have a built-in debug version.

This time introduce how to compile a debug version

experiment

We first prepare an environment with docker installed.The reason for using containers is that after conducting various experiments, we can destroy the containers and rebuild them to keep the system environment clean and unified, which is very convenient.

First open a devtoolset container:

Confirm that you are in the container:

Download the MySQL source package and unzip it:

Next, install the dependency packages, which are divided into 3 types of dependencies: tools for compilation, dependency packages for MySQL, and dependency packages for enabling DTRACE debugging.

(DTRACE debugging function we will introduce later)

Create a build directory, and then MySQL will put the compiled process files and results in this folder:

Configure compilation:

After a large amount of output, you can see the successful configuration information:

Now it can be officially compiled:

After a long and colorful output, the compilation was successful:

In the build/sql folder, a debug version of mysqld has been formed:

Tips

How to compile official MySQL like the official one?

In the configuration link, in the cmake command, replace -DWITH_DEBUG=1 with -DBUILD_CONFIG=mysql_release.

Why do we need a debug version of MySQL?

In question 35, we used the gdb debugger to limit the behavior of MySQL to study related mechanisms.

When MySQL is compiled, it will make some optimizations and erase some debugging information to improve performance. These erased debugging information are what we need when using the debugger.

We compiled the debug version of MySQL by ourselves, and with the blessing of this information, we can use more debugging methods.

Of course, retaining the debugging information means that the operating performance will be reduced, so the debug version of MySQL cannot be used for performance testing.


What else do you want to know about the technical content of MySQL? Hurry up and leave a message to tell the editor!


爱可生开源社区
429 声望211 粉丝

成立于 2017 年,以开源高质量的运维工具、日常分享技术干货内容、持续的全国性的社区活动为社区己任;目前开源的产品有:SQL审核工具 SQLE,分布式中间件 DBLE、数据传输组件DTLE。


引用和评论

0 条评论