源码编译安装MySQL Debug版本
安装依赖包
## 5.7
yum -y install ncurses-devel bison openssl-devel cmake centos-release-scl devtoolset-7
scl enable devtoolset-7 bash
## 8.0
wget https://cmake.org/files/v3.5/cmake-3.5.2.tar.gz
tar xf cmake-3.5.2.tar.gz
cd cmake-3.5.2
./bootstrap
make -j 8
make install
yum -y install ncurses-devel bison openssl-devel centos-release-scl devtoolset-10
scl enable devtoolset-10 bash
下载MySQL源码并编译Debug版本
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-boost-8.0.26.tar.gz
tar zxvf mysql-boost-8.0.26.tar.gz
cd mysql-8.0.26
## 编译为DEBUG版本
cmake . \
-DWITH_DEBUG=1 \
-DWITH_BOOST=./boost/ \
-DCMAKE_INSTALL_PREFIX=/data/mysql/8.0.32/base \
-DFORCE_INSOURCE_BUILD=1make -j4 && make install## 初始化并启动MySQL...
配置VSCode
VSCode安装Remote-SSH、C/C++和扩展插件及GDB Debug,如下:
配置调试文件
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Remote-GDB-Attach-MySQL",
"type": "cppdbg",
"request": "attach",
"program": "/data/mysql/8.0.32/base/bin/mysqld",
"processId": "${command:pickProcess}", "miDebuggerPath": "/usr/bin/gdb",
"MIMode": "gdb",
"setupCommands": [
{
"description": "远程调试MySQL",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
},
{
"name": "CoreDump",
"type": "cppdbg",
"request": "launch",
"program": "/usr/local/mysql/bin/mysqld",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"coreDumpPath": "/tmp/core-mysqld-6-0-0-30342-1655369975"
}
]
}