我可以使用gcloud sql命令在我的Google Cloud Sql实例上运行sql文件吗 [英] Can I run an sql file on my Google Cloud Sql instance using the gcloud sql command

查看:48
本文介绍了我可以使用gcloud sql命令在我的Google Cloud Sql实例上运行sql文件吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个sql文件,用于创建我的mysql数据库以及所有用户和表.

I have an sql file that creates my mysql database and all my users and tables.

我正在尝试找出一种方法,可以使用此sql文件自动在我的Google Cloud sql实例上初始化数据库.

I am trying to figure out of there is a way I can automate using this sql file to initialize the database on my Google Cloud sql instance.

到目前为止,我能够确定的唯一方法是使用 gcloud sql connect 命令,然后将sql文件的内容复制并粘贴到mysql提示符中.

So far, the only way I have been able to determine, is that I use the gcloud sql connect command, and then just copy and paste the contents of the sql file into the mysql prompt.

不过,必须有一个更好的方法.查看gcloud sql文档,我一直找不到.我想念什么吗?

There has got to be a better way though. Looking through the gcloud sql docs, I have not been able to find one. Am I missing something?

推荐答案

gcloud sql 面向管理Cloud SQL实例.

gcloud sql is oriented towards managing the Cloud SQL instance.

创建实例后,可以使用任何常规的MySQL工具与实例进行交互,包括创建表.

Once you've created an instance, you may use any regular MySQL tool to interact with the instance including creating tables.

例如,请参见: https://cloud.google.com/sql/docs/mysql/connect-admin-proxy

我建议您使用Google的Cloud SQL代理连接到远程实例,请参见: https://cloud.google.com/sql/docs/mysql/quickstart-proxy-test

I encourage you to use Google's Cloud SQL proxy to connect to the remote instance, see: https://cloud.google.com/sql/docs/mysql/quickstart-proxy-test

这篇关于我可以使用gcloud sql命令在我的Google Cloud Sql实例上运行sql文件吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆