Bird
0
0

If you run:

medium📝 Predict Output Q5 of 15
GCP - Cloud SQL and Databases
If you run:
cloud_sql_proxy -instances=my-project:us-central1:my-instance=tcp:5432
and then execute:
psql -h 127.0.0.1 -p 5432 -U user dbname
what is the expected outcome?
Apsql fails because port 5432 is not forwarded by the proxy
Bpsql connects successfully to the Cloud SQL PostgreSQL instance via the proxy
Cpsql connects to a local PostgreSQL server instead of Cloud SQL
Dpsql returns a syntax error due to incorrect command
Step-by-Step Solution
Solution:
  1. Step 1: Proxy port forwarding

    The proxy listens on localhost:5432 and forwards connections to Cloud SQL.
  2. Step 2: psql connection

    psql connecting to 127.0.0.1:5432 will connect through the proxy to Cloud SQL.
  3. Final Answer:

    psql connects successfully to the Cloud SQL PostgreSQL instance via the proxy -> Option B
  4. Quick Check:

    Proxy forwards port 5432 for PostgreSQL [OK]
Quick Trick: psql connects via proxy on forwarded port [OK]
Common Mistakes:
  • Assuming port 5432 is not forwarded
  • Thinking psql connects locally by default
  • Confusing command syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GCP Quizzes