Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect to postgresql google cloud sql instance? Need to import postgresql dump using pg_restore command

I have a google cloud sql postgresql instance. When I try to import postgresql dump I get following error.

enter image description here

I am able to connect to instance with the command given below.

gcloud sql connect instance-name --user postgres

It takes me to the psql command line client where I can not use database restore command like pg_restore

Does anyone have an idea on how can I actually connect to Google Cloud SQL instance so that I can perform operation such as pg_restore?

like image 394
Akshay Mohite Avatar asked Sep 11 '25 19:09

Akshay Mohite


1 Answers

if you need pg_restore can simply use:

gcloud sql connect instance-name --user postgres < dbbackup.sql

where dbbackup.sql is a file obtained from:

pg_dump olddb --format=plain --no-owner -v >> dbbackup.sql

like image 136
Phil Avatar answered Sep 13 '25 09:09

Phil