sth*_*mps 5 google-cloud-sql google-cloud-platform google-cloud-shell
我想使用Cloud Shell在我的第二代Cloud Sql实例上运行数据库迁移.
我在文档中找到了如何使用连接的示例gcloud.但是当我运行命令我得到一个错误:
$ gcloud beta sql connect my-instance --user=root
ERROR: (gcloud.beta.sql.connect) Invalid instance property.
Run Code Online (Sandbox Code Playgroud)
但是,即使这确实有效,我也不确定如何从执行迁移的python脚本连接.我会使用什么连接字符串?我是否需要手动将Cloud Shell IP列入白名单以进行访问?
编辑
上面的说明不起作用,它显示另一条消息。
第一次您需要运行以下命令:
gcloud beta sql connect <instance id> --project <project id>:us-central1 --user root
另外,我在控制台中切换到我的项目:
gcloud config set project <project id>
但是,我现在收到另一个错误:
ERROR: (gcloud.beta.sql.connect) The client is not authorized to make this request.
我想我需要让客户...
另一个编辑重新允许客户端
为了最终连接到数据库,我安装了Google SQL Proxy。
我用 FUSE 进行设置(我使用 Mac)。按照 Google 文档中的说明打开连接后。我能够通过 mysql 命令行进行连接。
$ mysql -u root -p -S <localtion of cloud sql proxy folder>/<project id>:us-central1:<db instance id>
原来的
刚刚弄清楚了这一点。操作方法如下:
单击您要连接的实例
在Overview部分中,向下滚动到Properties。
在Properties你会看到Instance connection name。它看起来像<your project>:us-central1:<instance name>
在命令中使用它:
$ gcloud beta sql connect <your project>:us-central1:<instance name> --user root
| 归档时间: |
|
| 查看次数: |
10458 次 |
| 最近记录: |