使用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=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"
        }
    ]
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值