简体   繁体   English

如何连接到postgresql google云sql实例? 需要使用pg_restore命令导入postgresql转储

[英]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. 我有一个google cloud sql postgresql实例。 When I try to import postgresql dump I get following error. 当我尝试导入postgresql转储时,我收到以下错误。

在此输入图像描述

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 它带我到psql命令行客户端,我不能使用像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? 有没有人知道如何实际连接到Google Cloud SQL实例,以便我可以执行pg_restore等操作?

if you need pg_restore can simply use: 如果你需要pg_restore可以简单地使用:

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

where dbbackup.sql is a file obtained from: 其中dbbackup.sql是从以下位置获得的文件:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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