1

I am trying to establish a Cloud SQL proxy connection with Google Cloud. Below is my 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"

        }

When I run the command npm run db:proxy the following ERROR shows up:

> ./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?

I am on a Windows 10 64-bit machine and uses cmd and have Google Cloud Shell installed and its PATH set and is saved in the root directory of where I am running the program from. Why does the error shows up. Is the error related to PATH?.

I tried replacing

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

with

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

Still the error persists.

Running the command

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

on my cmd inside the folder where Cloud SDK has been installed works perfectly fine.

So Is the problem that it is unable to find .\cloud_sql_program?

I have set the PATH as follows:

C:\Users\user_name\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin
Wytrzymały Wiktor
  • 11,492
  • 5
  • 29
  • 37
Hari Krishnan U
  • 166
  • 5
  • 16
  • Check this [link](https://stackoverflow.com/questions/50549063/problems-installing-cloud-sql-proxy-on-windows-64-bit) once – Sri Aug 30 '21 at 11:47
  • @Sri I am able to start the cloud SQL proxy from Google Cloud SDK Shell and it works perfectly fine. – Hari Krishnan U Aug 30 '21 at 12:01
  • Using this command **.\cloud_sql_proxy** will NOT work on Cloud Shell. Using the command **./cloud_sql_proxy** will NOT work on Windows. Double-check the details in your question. – John Hanley Aug 30 '21 at 19:13
  • Does it need the .\ prefix? Maybe try just plain `cloud_sql_proxy`? – Hitobat Aug 30 '21 at 20:36

1 Answers1

1

According to Cloud SQL Auth proxy download instructions for Windows, you need to download proxy and rename the file as follows:

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.

Further in the docs, part Cloud SQL Auth proxy invocations and mysql client connection strings , you can see the command format for Windows in the following example:

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

You can try using this example as a guide for the correct command format.

Farid Shumbar
  • 1,360
  • 3
  • 10