Windows 使用VSCode远程连接到Linux开发调试MySQL

举报
eric0435 发表于 2021/12/17 10:03:58 2021/12/17
【摘要】 Windows 使用VSCode远程连接到Linux开发调试MySQL1.Linux系统上安装相关开发工具[root@gbase yum.repos.d]# yum install gdb-gdbserver[root@gbase yum.repos.d]# yum install gdb[root@gbase yum.repos.d]# yum install gcc[root@gbase...

Windows 使用VSCode远程连接到Linux开发调试MySQL


1.Linux系统上安装相关开发工具

[root@gbase yum.repos.d]# yum install gdb-gdbserver

[root@gbase yum.repos.d]# yum install gdb

[root@gbase yum.repos.d]# yum install gcc

[root@gbase yum.repos.d]# yum install cmake


2.配置VSCode可以免密登录Linux

2.1在Windows上生成密钥


C:\Users\Administrator>ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (C:\Users\Administrator\.ssh\id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in id_rsa.

Your public key has been saved in id_ras.pub.

The key fingerprint is:

SHA256:2ya72QX0JQBxKTLM+3S1H3FFYnHHrve1t0cSbqXJiqI mysql@gbase

The key's randomart image is:

+---[RSA 2048]----+

| o ooo. ++*|

| = .......o+|

| + ......+ |

| . .....oo o|

| oS.. .+ B |

| .o . X +|

| o o..o ++|

| .*... .+|

| E.+o. .+|

+----[SHA256]-----+





2.2 在Linux服务器上生成密钥

[root@gbase ~]# su - mysql

Last login: Sun Sep 26 09:24:11 CST 2021 on pts/5

[mysql@gbase ~]$ pwd

/home/mysql

[mysql@gbase ~]$ ls -lrt

total 0

drwxrwxr-x. 2 mysql mysql 6 Sep 24 16:19 perl5

[mysql@gbase ~]$ cd ~/.ssh

-bash: cd: /home/mysql/.ssh: No such file or directory

[mysql@gbase ~]$ mkdir ~/.ssh

[mysql@gbase ~]$ cd ~/.ssh

[mysql@gbase .ssh]$ pwd

/home/mysql/.ssh

[mysql@gbase .ssh]$ ls -lrt

total 0


增加root权限:visudo 进入文本后找到root ALL=(ALL) ALL,另起一行,加入admin ALL=(ALL) NOPASSWD:ALL su admin 切换到新用户 再使

用sudo su -切换回root,说明权限正常,进行下一步


[root@gbase ~]# visudo

## Allow root to run any commands anywhere

root ALL=(ALL) ALL

mysql ALL=(ALL) NOPASSWD:ALL



[mysql@gbase ~]$ sudo su -

Last login: Sun Sep 26 11:41:38 CST 2021 on pts/1

[root@gbase ~]# su - mysql

Last login: Sun Sep 26 14:20:50 CST 2021 from 192.168.1.12 on pts/3

[mysql@gbase ~]$




2.3将windows中生成的公钥上传到/home/mysql/.ssh/目录

C:\Users\Administrator>scp C:\Users\Administrator\.ssh\id_rsa.pud mysql@192.168.1.249:/home/mysql/.ssh/authorized_keys


[mysql@gbase ~]$ chmod 700 /home/mysql/.ssh

[mysql@gbase ~]$ chmod 600 /home/mysql/.ssh/authorized_keys


2.4切换到root,关闭root登录 sudo su - vim /etc/ssh/sshd_config 找到#PermitRootLogin yes去掉#把yes改为no systemctl restart sshd 重启服务并生效

[root@gbase .ssh]# vim /etc/ssh/sshd_config

# $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $


# This is the sshd server system-wide configuration file. See

# sshd_config(5) for more information.


# This sshd was compiled with PATH=/usr/local/bin:/usr/bin


# The strategy used for options in the default sshd_config shipped with

# OpenSSH is to specify options with their default value where

# possible, but leave them commented. Uncommented options override the

# default value.


# If you want to change the port on a SELinux system, you have to tell

# SELinux about this change.

# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER

#

Port 22

#AddressFamily any

#ListenAddress 0.0.0.0

#ListenAddress ::


HostKey /etc/ssh/ssh_host_rsa_key

#HostKey /etc/ssh/ssh_host_dsa_key

HostKey /etc/ssh/ssh_host_ecdsa_key

HostKey /etc/ssh/ssh_host_ed25519_key


# Ciphers and keying

#RekeyLimit default none


# Logging

#SyslogFacility AUTH

SyslogFacility AUTHPRIV

#LogLevel INFO


# Authentication:


#LoginGraceTime 2m

PermitRootLogin no #改成no

#StrictModes yes

#MaxAuthTries 6

#MaxSessions 10

RSAAuthentication yes #要开启

PubkeyAuthentication yes #要开启


# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2

# but this is overridden so installations will only check .ssh/authorized_keys

AuthorizedKeysFile .ssh/authorized_keys



[root@gbase ~]# service sshd restart

Redirecting to /bin/systemctl restart sshd.service



在windows中测试ssh登录

C:\Users\Administrator>ssh mysql@192.168.1.249

Last login: Sun Sep 26 14:22:54 2021



]ysql@gbase:~[mysql@gbase ~]$ pwd

/home/mysql






2.5 配置vscode通过remote ssh连接Linux的配置文件C:\Users\Administrator\.ssh\config

Host 192.168.1.249

HostName 192.168.1.249

User root

IdentityFile "D:\ssh\vscode"



2.6 通过vscode远程连接Linux服务器出现以下错误


> Waiting for client to transfer server archive...

> Waiting for /home/mysql/.vscode-server/bin/7f6ab5485bbc008386c4386d08766667e1552

> 44e/vscode-scp-done.flag and vscode-server.tar.gz to exist

>

[12:31:20.267] Got request to download on client for {"platform":"linux","arch":"x64","destFolder":"/home/mysql/.vscode-server/bin/7f6ab5485bbc008386c4386d08766667e155244e"}

[12:31:20.268] Downloading VS Code server locally...

[12:31:20.420] Resolver error: Error: Running the contributed command: '_workbench.downloadResource' failed.


[mysql@gbase /]$ cd /home/mysql

[mysql@gbase ~]$ ls -lrt .vscode-server

total 0

drwxrwxr-x. 3 mysql mysql 54 Sep 26 09:46 bin

[mysql@gbase ~]$ cd .vscode-server

[mysql@gbase .vscode-server]$ ls

bin

[mysql@gbase .vscode-server]$ cd bin

[mysql@gbase bin]$ ls

7f6ab5485bbc008386c4386d08766667e155244e


[mysql@gbase bin]$ cd 7f6ab5485bbc008386c4386d08766667e155244e/

[mysql@gbase 7f6ab5485bbc008386c4386d08766667e155244e]$ ls

vscode-remote-lock.mysql.7f6ab5485bbc008386c4386d08766667e155244e vscode-server.tar.gz

[mysql@gbase 7f6ab5485bbc008386c4386d08766667e155244e]$ ls -lrt

total 0

-rw-rw-r--. 1 mysql mysql 0 Sep 26 11:37 vscode-remote-lock.mysql.7f6ab5485bbc008386c4386d08766667e155244e

-rw-rw-r--. 1 mysql mysql 0 Sep 26 11:37 vscode-server.tar.gz


上面的7f开头的文件夹称为Commit Id,现在利用Commit ID下载远程连接需要的文件。对于Stabe Version(在VS Code报错的的窗口中Ctrl+F

搜索stable,有则为Stable Version)的Remote SSH插件,如下图,在“输出”窗口中Ctrl+F搜索“stable”。


[12:31:14.904] Using commit id "7f6ab5485bbc008386c4386d08766667e155244e" and quality "stable" for server


然后使用这个链接:https://update.code.visualstudio.com/commit:$COMMIT_ID/server-linux-x64/stable下载所需文件,注意链接中的

$COMMIT_ID这几个字符(注意$不要忘记)需要换成自己的,比如我的是 7f6ab5485bbc008386c4386d08766667e155244e,那么此时我通

过https://update.code.visualstudio.com/commit:7f6ab5485bbc008386c4386d08766667e155244e/server-linux-x64/stable就可以下载到

我需要的文件。


对于Insider版本,

通过https://update.code.visualstudio.com/commit:7f6ab5485bbc008386c4386d08766667e155244e/server-linux-x64/insider这个链接下载相

应文件。

下载完毕后,将下载的文件upload到Remote Server的~/.vscode-server/bin/xxx文件夹下(也可以在Remote Server上直接

执行wget https://vscode.cdn.azure.cn/stable/7f6ab5485bbc008386c4386d08766667e155244e/vscode-server-linux-x64.tar.gz即可下载,

这样就不用进行上传操作了),同时删除其他文件,最后再使用tar -xvf vscode-server-linux-x64.tar.gz --strip-components 1解压文件,


sftp> put D:\ssh\vscode-server-linux-x64.tar.gz

Uploading vscode-server-linux-x64.tar.gz to /home/mysql/vscode-server-linux-x64.tar.gz

100% 45296KB 45296KB/s 00:00:00

D:/ssh/vscode-server-linux-x64.tar.gz: 46383314 bytes transferred in 0 seconds (45296 KB/s)


[mysql@gbase 7f6ab5485bbc008386c4386d08766667e155244e]$ tar -xvf vscode-server-linux-x64.tar.gz --strip-components 1


然后使用chmod +x node server.sh为node和server.sh添加可执行权限。

[mysql@gbase 7f6ab5485bbc008386c4386d08766667e155244e]$ chmod +x node server.sh

[mysql@gbase 7f6ab5485bbc008386c4386d08766667e155244e]$ ls -lrt

total 117512

-rwxr-xr-x. 1 mysql mysql 222 Sep 22 20:00 server.sh

-rw-r--r--. 1 mysql mysql 34147 Sep 22 20:00 product.json

-rw-r--r--. 1 mysql mysql 1255 Sep 22 20:00 package.json

-rw-r--r--. 1 mysql mysql 13380 Sep 22 20:00 LICENSE

-rwxr-xr-x. 1 mysql mysql 73873984 Sep 22 20:02 node

drwxr-xr-x. 3 mysql mysql 135 Sep 22 20:02 out

drwxr-xr-x. 3 mysql mysql 33 Sep 22 20:02 bin

drwxr-xr-x. 32 mysql mysql 4096 Sep 22 20:02 extensions

drwxr-xr-x. 78 mysql mysql 4096 Sep 22 20:02 node_modules

-rw-rw-r--. 1 mysql mysql 0 Sep 26 11:37 vscode-remote-lock.mysql.7f6ab5485bbc008386c4386d08766667e155244e

-rw-rw-r--. 1 mysql mysql 0 Sep 26 11:37 vscode-server.tar.gz

-rw-rw-r--. 1 mysql mysql 46383314 Sep 26 11:57 vscode-server-linux-x64.tar.gz



再次使用VS Code尝试链接,这一步会链接成功。



3.vscode在远程远程服务器上依次安装 C/C++、CMake、CMake Tools插件






在使用vscode 远程调试程序时出现以下信息:

Updating C/C++ dependencies...


Downloading package 'C/C++ language components (Linux / x86_64)' Failed. Retrying... Failed. Retrying... Failed. Retrying...Waiting 8 seconds... Failed. Retrying...Waiting 15 seconds... Failed. Retrying...Waiting 15 seconds... Failed. Retrying...Waiting 15 seconds... Failed. Retrying...Waiting 15 seconds... Failed. Retrying...Waiting 15 seconds... Failed. Retrying...Waiting 15 seconds... Failed to download https://go.microsoft.com/fwlink/?linkid=2170969

Failed at stage: downloadPackages

Error: getaddrinfo ENOTFOUND go.microsoft.com

    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26)


If you work in an offline environment or repeatedly see this error, try downloading a version of the extension with all the dependencies pre-included from https://github.com/microsoft/vscode-cpptools/releases, then use the "Install from VSIX" command in VS Code to install it.





安装 C/C++ language components插件失败


我们只能手动安装

打开网址https://go.microsoft.com/fwlink/?linkid=2170969下载bin_linupwd

x.zip文件


将bin_linux.zip文件解压

cpptools

cpptools-srv

LICENSE.txt


将这三个文件拷贝到远程Linux服务器的/home/mysql/.vscode-server/extensions/ms-vscode.cpptools-1.6.0/bin目录中

如果原先存在这个文件的话先将其备份。


sftp> put F:\bin_linux\bin\*

Uploading cpptools to /home/mysql/.vscode-server/extensions/ms-vscode.cpptools-1.6.0/bin/cpptools

100% 19544KB 19544KB/s 00:00:00

F:/bin_linux/bin/cpptools: 20014008 bytes transferred in 0 seconds (19544 KB/s)

Uploading cpptools-srv to /home/mysql/.vscode-server/extensions/ms-vscode.cpptools-1.6.0/bin/cpptools-srv

100% 11508KB 11508KB/s 00:00:00

F:/bin_linux/bin/cpptools-srv: 11784664 bytes transferred in 0 seconds (11508 KB/s)

Uploading LICENSE.txt to /home/mysql/.vscode-server/extensions/ms-vscode.cpptools-1.6.0/bin/LICENSE.txt

100% 11KB 11KB/s 00:00:00

F:/bin_linux/bin/LICENSE.txt: 11972 bytes transferred in 0 seconds (11 KB/s)


但是没有用,仍然报错

如是通过vsix来进行安装

githubrelease好多个版本,我远程看代码的主机是redhat Linux系统,所有下载cpptools-linux.vsix


先删除我们上传到/home/mysql/.vscode-server/extensions/ms-vscode.cpptools-1.6.0/bin的三个文件

[mysql@gbase bin]$ ls -lrt

total 31188

-rw-rw-r--. 1 mysql mysql 11784664 Aug 23 22:29 cpptools-srv

-rw-rw-r--. 1 mysql mysql 20014008 Aug 23 22:29 cpptools

-rw-rw-r--. 1 mysql mysql 11972 Aug 23 22:34 LICENSE.txt

-rw-rw-r--. 1 mysql mysql 582 Sep 26 12:05 common.json

-rw-rw-r--. 1 mysql mysql 301 Sep 26 12:05 linux.clang.arm.json

-rw-rw-r--. 1 mysql mysql 310 Sep 26 12:05 linux.clang.arm64.json

-rw-rw-r--. 1 mysql mysql 300 Sep 26 12:05 linux.clang.x64.json

-rw-rw-r--. 1 mysql mysql 291 Sep 26 12:05 linux.clang.x86.json

-rw-rw-r--. 1 mysql mysql 301 Sep 26 12:05 linux.gcc.arm.json

-rw-rw-r--. 1 mysql mysql 310 Sep 26 12:05 linux.gcc.arm64.json

-rw-rw-r--. 1 mysql mysql 302 Sep 26 12:05 linux.gcc.x64.json

-rw-rw-r--. 1 mysql mysql 291 Sep 26 12:05 linux.gcc.x86.json

-rw-rw-r--. 1 mysql mysql 284 Sep 26 12:05 macos.clang.arm.json

-rw-rw-r--. 1 mysql mysql 293 Sep 26 12:05 macos.clang.arm64.json

-rw-rw-r--. 1 mysql mysql 283 Sep 26 12:05 macos.clang.x64.json

-rw-rw-r--. 1 mysql mysql 274 Sep 26 12:05 macos.clang.x86.json

-rw-rw-r--. 1 mysql mysql 284 Sep 26 12:05 macos.gcc.arm.json

-rw-rw-r--. 1 mysql mysql 293 Sep 26 12:05 macos.gcc.arm64.json

-rw-rw-r--. 1 mysql mysql 283 Sep 26 12:05 macos.gcc.x64.json

-rw-rw-r--. 1 mysql mysql 274 Sep 26 12:05 macos.gcc.x86.json

drwxrwxr-x. 15 mysql mysql 145 Sep 26 12:05 messages

-rw-rw-r--. 1 mysql mysql 87 Sep 26 12:05 windows.clang.arm.json

-rw-rw-r--. 1 mysql mysql 87 Sep 26 12:05 windows.clang.arm64.json

-rw-rw-r--. 1 mysql mysql 87 Sep 26 12:05 windows.clang.x64.json

-rw-rw-r--. 1 mysql mysql 87 Sep 26 12:05 windows.clang.x86.json

-rw-rw-r--. 1 mysql mysql 87 Sep 26 12:05 windows.gcc.arm.json

-rw-rw-r--. 1 mysql mysql 89 Sep 26 12:05 windows.gcc.arm64.json

-rw-rw-r--. 1 mysql mysql 87 Sep 26 12:05 windows.gcc.x64.json

-rw-rw-r--. 1 mysql mysql 87 Sep 26 12:05 windows.gcc.x86.json

-rw-rw-r--. 1 mysql mysql 299 Sep 26 12:05 windows.msvc.arm.json

-rw-rw-r--. 1 mysql mysql 324 Sep 26 12:05 windows.msvc.arm64.json

-rw-rw-r--. 1 mysql mysql 383 Sep 26 12:05 windows.msvc.x64.json

-rw-rw-r--. 1 mysql mysql 359 Sep 26 12:05 windows.msvc.x86.json

[mysql@gbase bin]$ rm -rf cpptools*

[mysql@gbase bin]$ rm -rf LICENSE.txt

[mysql@gbase bin]$ ls -lrt

total 116

-rw-rw-r--. 1 mysql mysql 582 Sep 26 12:05 common.json

-rw-rw-r--. 1 mysql mysql 301 Sep 26 12:05 linux.clang.arm.json

-rw-rw-r--. 1 mysql mysql 310 Sep 26 12:05 linux.clang.arm64.json

-rw-rw-r--. 1 mysql mysql 300 Sep 26 12:05 linux.clang.x64.json

-rw-rw-r--. 1 mysql mysql 291 Sep 26 12:05 linux.clang.x86.json

-rw-rw-r--. 1 mysql mysql 301 Sep 26 12:05 linux.gcc.arm.json

-rw-rw-r--. 1 mysql mysql 310 Sep 26 12:05 linux.gcc.arm64.json

-rw-rw-r--. 1 mysql mysql 302 Sep 26 12:05 linux.gcc.x64.json

-rw-rw-r--. 1 mysql mysql 291 Sep 26 12:05 linux.gcc.x86.json

-rw-rw-r--. 1 mysql mysql 284 Sep 26 12:05 macos.clang.arm.json

-rw-rw-r--. 1 mysql mysql 293 Sep 26 12:05 macos.clang.arm64.json

-rw-rw-r--. 1 mysql mysql 283 Sep 26 12:05 macos.clang.x64.json

-rw-rw-r--. 1 mysql mysql 274 Sep 26 12:05 macos.clang.x86.json

-rw-rw-r--. 1 mysql mysql 284 Sep 26 12:05 macos.gcc.arm.json

-rw-rw-r--. 1 mysql mysql 293 Sep 26 12:05 macos.gcc.arm64.json

-rw-rw-r--. 1 mysql mysql 283 Sep 26 12:05 macos.gcc.x64.json

-rw-rw-r--. 1 mysql mysql 274 Sep 26 12:05 macos.gcc.x86.json

drwxrwxr-x. 15 mysql mysql 145 Sep 26 12:05 messages

-rw-rw-r--. 1 mysql mysql 87 Sep 26 12:05 windows.clang.arm.json

-rw-rw-r--. 1 mysql mysql 87 Sep 26 12:05 windows.clang.arm64.json

-rw-rw-r--. 1 mysql mysql 87 Sep 26 12:05 windows.clang.x64.json

-rw-rw-r--. 1 mysql mysql 87 Sep 26 12:05 windows.clang.x86.json

-rw-rw-r--. 1 mysql mysql 87 Sep 26 12:05 windows.gcc.arm.json

-rw-rw-r--. 1 mysql mysql 89 Sep 26 12:05 windows.gcc.arm64.json

-rw-rw-r--. 1 mysql mysql 87 Sep 26 12:05 windows.gcc.x64.json

-rw-rw-r--. 1 mysql mysql 87 Sep 26 12:05 windows.gcc.x86.json

-rw-rw-r--. 1 mysql mysql 299 Sep 26 12:05 windows.msvc.arm.json

-rw-rw-r--. 1 mysql mysql 324 Sep 26 12:05 windows.msvc.arm64.json

-rw-rw-r--. 1 mysql mysql 383 Sep 26 12:05 windows.msvc.x64.json

-rw-rw-r--. 1 mysql mysql 359 Sep 26 12:05 windows.msvc.x86.json


通过vscode 从vsix来进行安装,选择本地目录D:\ssh\cpptools-linux.vsix文件


[mysql@gbase bin]$ ls -lrt

total 31188

-rw-rw-r--. 1 mysql mysql 582 Sep 26 15:01 common.json

-rw-rw-r--. 1 mysql mysql 20014008 Sep 26 15:01 cpptools

-rw-rw-r--. 1 mysql mysql 11784664 Sep 26 15:01 cpptools-srv

-rw-rw-r--. 1 mysql mysql 11972 Sep 26 15:01 LICENSE.txt

-rw-rw-r--. 1 mysql mysql 301 Sep 26 15:01 linux.clang.arm.json

-rw-rw-r--. 1 mysql mysql 310 Sep 26 15:01 linux.clang.arm64.json

-rw-rw-r--. 1 mysql mysql 300 Sep 26 15:01 linux.clang.x64.json

-rw-rw-r--. 1 mysql mysql 291 Sep 26 15:01 linux.clang.x86.json

-rw-rw-r--. 1 mysql mysql 301 Sep 26 15:01 linux.gcc.arm.json

-rw-rw-r--. 1 mysql mysql 310 Sep 26 15:01 linux.gcc.arm64.json

-rw-rw-r--. 1 mysql mysql 302 Sep 26 15:01 linux.gcc.x64.json

-rw-rw-r--. 1 mysql mysql 291 Sep 26 15:01 linux.gcc.x86.json

-rw-rw-r--. 1 mysql mysql 284 Sep 26 15:01 macos.clang.arm.json

-rw-rw-r--. 1 mysql mysql 293 Sep 26 15:01 macos.clang.arm64.json

-rw-rw-r--. 1 mysql mysql 283 Sep 26 15:01 macos.clang.x64.json

-rw-rw-r--. 1 mysql mysql 274 Sep 26 15:01 macos.clang.x86.json

-rw-rw-r--. 1 mysql mysql 284 Sep 26 15:01 macos.gcc.arm.json

-rw-rw-r--. 1 mysql mysql 293 Sep 26 15:01 macos.gcc.arm64.json

-rw-rw-r--. 1 mysql mysql 283 Sep 26 15:01 macos.gcc.x64.json

-rw-rw-r--. 1 mysql mysql 274 Sep 26 15:01 macos.gcc.x86.json

drwxrwxr-x. 15 mysql mysql 145 Sep 26 15:01 messages

-rw-rw-r--. 1 mysql mysql 87 Sep 26 15:01 windows.clang.arm.json

-rw-rw-r--. 1 mysql mysql 87 Sep 26 15:01 windows.clang.arm64.json

-rw-rw-r--. 1 mysql mysql 87 Sep 26 15:01 windows.clang.x64.json

-rw-rw-r--. 1 mysql mysql 87 Sep 26 15:01 windows.clang.x86.json

-rw-rw-r--. 1 mysql mysql 87 Sep 26 15:01 windows.gcc.arm.json

-rw-rw-r--. 1 mysql mysql 89 Sep 26 15:01 windows.gcc.arm64.json

-rw-rw-r--. 1 mysql mysql 87 Sep 26 15:01 windows.gcc.x64.json

-rw-rw-r--. 1 mysql mysql 87 Sep 26 15:01 windows.gcc.x86.json

-rw-rw-r--. 1 mysql mysql 299 Sep 26 15:01 windows.msvc.arm.json

-rw-rw-r--. 1 mysql mysql 324 Sep 26 15:01 windows.msvc.arm64.json

-rw-rw-r--. 1 mysql mysql 383 Sep 26 15:01 windows.msvc.x64.json

-rw-rw-r--. 1 mysql mysql 359 Sep 26 15:01 windows.msvc.x86.json


重启vscdoe





4.使用vscode远程编译Linux服务器的MySQL源码,mysql源码在/soft/mysql-5.7.26/目录


这里需要配置Cmake 生成setting.json配置文件 点击CMake Tool的设置按钮,再点击Extention Settings

这里选择Remote [SSH:192.168.1.249],我这对于Build Directory选择使用默认配置,因为${workspaceFolder}就是/soft/mysql-5.7.26目录,所以$${workspaceFolder}/build也就是/soft/mysql-5.7.26/build目录



所以Source Directory目录选择使用默认的$workspaceFolder}目录









给Configure Args配置以下三个参数

-DWITH_BOOST=/soft/mysql-5.7.26/boost/boost_1_59_0

-DDOWNLOAD_BOOST=1

-DWITH_DEBUG=1


选择编译器









给CMake选择Debug模式

然后进行编译


编译完成后,在Linux服务器上初始化mysql数据库

创建data,etc目录用来分别存放数据文件与配置文件my.cnf

[mysql@gbase build]$ mkdir {data,etc}

[mysql@gbase build]$ cd etc

[mysql@gbase etc]$ vi my.cnf

[mysqld]

basedir=/soft/mysql-5.7.26/build

datadir=/soft/mysql-5.7.26/build/data

bind-address=0.0.0.0

user=mysql

port=3306

log-error=/soft/mysql-5.7.26/build/data/mysql.err

pid-file=/soft/mysql-5.7.26/build/data/mysqld.pid

socket = /soft/mysql-5.7.26/build/data/mysql.sock

character-set-server=utf8mb4

default-storage-engine=INNODB

explicit_defaults_for_timestamp = true



[mysql@gbase build]$ sql/mysqld --defaults-file=etc/my.cnf --initialize-insecure

[mysql@gbase build]$ cd data

[mysql@gbase data]$ ls

auto.cnf ib_buffer_pool ibdata1 ib_logfile0 ib_logfile1 mysql mysql.err performance_schema sys

[mysql@gbase data]$ ls -lrt

total 110632

-rw-r-----. 1 mysql mysql 50331648 Sep 26 15:43 ib_logfile1

-rw-r-----. 1 mysql mysql 56 Sep 26 15:43 auto.cnf

-rw-r-----. 1 mysql mysql 1046 Sep 26 15:43 mysql.err

drwxr-x---. 2 mysql mysql 8192 Sep 26 15:43 performance_schema

drwxr-x---. 2 mysql mysql 4096 Sep 26 15:43 mysql

drwxr-x---. 2 mysql mysql 8192 Sep 26 15:43 sys

-rw-r-----. 1 mysql mysql 419 Sep 26 15:43 ib_buffer_pool

-rw-r-----. 1 mysql mysql 50331648 Sep 26 15:43 ib_logfile0

-rw-r-----. 1 mysql mysql 12582912 Sep 26 15:43 ibdata1

[mysql@gbase data]$ more mysql.err

2021-09-26T07:43:43.288066Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)

2021-09-26T07:43:43.288312Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)

2021-09-26T07:43:43.289227Z 0 [ERROR] Can't find error-message file '/soft/mysql-5.7.26/build/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.

2021-09-26T07:43:46.058883Z 0 [Warning] InnoDB: New log files created, LSN=45790

2021-09-26T07:43:46.360628Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

2021-09-26T07:43:46.558161Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 7b190ba6-1e9d-11ec-93d5-005056a31fca.

2021-09-26T07:43:46.567453Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.

2021-09-26T07:43:46.569018Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.






[mysql@gbase mysql-5.7.26]$ gcc -v -E -x c++ -

Using built-in specs.

COLLECT_GCC=gcc

Target: x86_64-redhat-linux

Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux

Thread model: posix

gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)

COLLECT_GCC_OPTIONS='-v' '-E' '-mtune=generic' '-march=x86-64'

/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/cc1plus -E -quiet -v -D_GNU_SOURCE - -mtune=generic -march=x86-64

ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/4.8.5/include-fixed"

ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../x86_64-redhat-linux/include"

#include "..." search starts here:

#include <...> search starts here:

/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5

/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/x86_64-redhat-linux

/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/backward

/usr/lib/gcc/x86_64-redhat-linux/4.8.5/include

/usr/local/include

/usr/include

将下面的内容加入到c_cpp_properties.json中的includePath

/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5

/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/x86_64-redhat-linux

/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/backward

/usr/lib/gcc/x86_64-redhat-linux/4.8.5/include

/usr/local/include

/usr/include



加入后错误信息消失

【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。