通过 Windows cmd 与 GCP、云 sql 代理建立连接时出错

Error in establishing connection with GCP, cloud sql proxy through Windows cmd

我正在尝试与 Google Cloud 建立 Cloud SQL 代理连接。下面是我的 package.json:

    {
        "name": "folder-name",
        "version": "1.0.0",
        "description": "",
        "main": "index.js",
        "scripts": {
         "test": "echo \"Error: no test specified\" && exit 1",
         "db:proxy": ".\cloud_sql_proxy -instances=vector-123456:us-east1:superdb=tcp:0.0.0.0:1234"
    },
          "author": "",
         "license": "ISC"

        }

当我 运行 命令 npm run db:proxy 出现以下错误时:

> ./cloud_sql_proxy -instances=vector-123456:us- east1:superdb=tcp:0.0.0.0:1234

'.' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hhhh@1.0.0 db:proxy: `.\cloud_sql_proxy -instances=vector-123456:us- east1:superdb=tcp:0.0.0.0:1234`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hhhh@1.0.0 db:proxy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

我在 Windows 10 64 位机器上使用 cmd 并且安装了 Google Cloud Shell 并且设置了它的 PATH 并保存在根目录中我所在的目录 运行ning 程序。为什么会出现错误。错误与PATH有关吗?

我试过替换

"db:proxy": ".\cloud_sql_proxy -instances=vector-123456:us-east1:superdb=tcp:0.0.0.0:1234"

"db:proxy: .\cloud_sql_proxy -instances=[vector-123456:us- east1:superdb]=tcp:0.0.0.0:1234"

错误仍然存​​在。

运行命令

.\cloud_sql_proxy -instances=vector-123456:us-east1:superdb=tcp:0.0.0.0:1234

在我的 cmd 安装了 Cloud SDK 的文件夹中工作得很好。

所以问题是找不到.\cloud_sql_program

我设置的路径如下:

C:\Users\user_name\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin

根据云端SQLAuth代理下载 说明为Windows,需要下载proxy并重命名文件如下:

Right-click https://dl.google.com/cloudsql/cloud_sql_proxy_x64.exe and select Save Link As to download the Cloud SQL Auth proxy. Rename the file to cloud_sql_proxy.exe.

进一步在文档中,部分 Cloud SQL Auth 代理调用和 mysql 客户端连接字符串 ,你可以在下面的例子中看到Windows的命令格式:

cloud_sql_proxy.exe -instances=myProject:us-central1:myInstance=tcp:3306
mysql -u myUser --host 127.0.0.1

您可以尝试使用此示例作为正确命令格式的指南。