Goal
- Access the postgres databases in Google Cloud Platform(GCP)‘s Cloud SQL from local machine with psql
Steps
- Install Cloud SQL Auth Proxy Client
curl -o cloud-sql-proxy https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.6.0/cloud-sql-proxy.darwin.amd64
chmod +x cloud-sql-proxy
- Run the cloud sql proxy with connection string
cloud-sql-proxy onec-dev:us-central1:built-object-service-dev-m1
- Connect the database with psql
psql "host=127.0.0.1 port=5432 sslmode=disable dbname= user="
References
Reference: this