7.9.1.1 编译 MySQL 进行调试
If you have some very specific problem, you can always try to debug MySQL. To do this you must configure MySQL with the -DWITH_DEBUG=1
option. You can check whether MySQL was compiled with debugging by doing: mysqld --help. If the --debug
flag is listed with the options then you have debugging enabled. mysqladmin ver also lists the mysqld version as mysql ... --debug in this case.
If mysqld stops crashing when you configure it with the -DWITH_DEBUG=1
CMake option, you probably have found a compiler bug or a timing bug within MySQL. In this case, you can try to add -g
using the CMAKE_C_FLAGS
and CMAKE_CXX_FLAGS
CMake options and not use -DWITH_DEBUG=1
. If mysqld dies, you can at least attach to it with gdb or use gdb on the core file to find out what happened.
When you configure MySQL for debugging you automatically enable a lot of extra safety check functions that monitor the health of mysqld. If they find something “unexpected,” an entry is written to stderr
, which mysqld_safe directs to the error log! This also means that if you are having some unexpected problems with MySQL and are using a source distribution, the first thing you should do is to configure MySQL for debugging. If you believe that you have found a bug, please use the instructions at Section 1.6, “How to Report Bugs or Problems”.
In the Windows MySQL distribution, mysqld.exe
is by default compiled with support for trace files.