使用VSCode远程调试MySQL
源码编译安装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=1
make -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" } ] }
随后就可以使用VSCode远程调试MySQL或分析MySQL Coredump文件。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?