简体   繁体   中英

cant connect database mysql through tcp forwarding

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM