0
votes

i want to access database in google cloud server via TCP Forwarding, I have username = root password = my-password , server-name

i am doing:

  1. Set TCP Forward in cloud server

gcloud compute start-iap-tunnel sg01dbcluster-node-2 3306 --local-host-port=localhost:3307 --zone=asia-southeast1-b

output :

Listening on port [3307].
  1. Then i connect to database server using mysql workbench hostname localhost port :3307 username : root password : my-password

but i have error:

Failed to Connect to MySQL at localhost:3307 with user root    
Lost connection to MySQL server at 'reading initial communication packet', system error: 0

any idea what step that i missed ?

1
the mysql database is installed on the instance you are accessing or it is a Cloud SQL instance? - breddy
the database was MongoDB Atlas @breddy - hinafaya
maybe you do not need the :3307 on --local-host-port flag. Take a look here - breddy
@breddy i have done following these tutorial and what should i do in the next ? - hinafaya
per this MongoDB atlas default port should be 27015. Did you change it to use port 3307? - breddy

1 Answers

0
votes

i have done fixing the connecting problem, before that i am sounding that i have a instances-name , username root and password my-password to connect database in cloud server (the database was sql) via TCP IP forwarding. cloud server was google cloud compute engine. here are the step:

in local

  1. gcloud config set (i am using config set project and zone, don't forget using alpha/beta if the code doesn't running)

  2. TCP Other connection (check last section)

    gcloud beta compute start-iap-tunnel my-instances-name 3306 --local-host-port=localhost:3309

wait a second until show:

Listening Port [3309]
  1. Open mysql workbench and put the hostname : localhost , port : 3309 , username : root , password : my-password