如何在CloudSQL中保留MySQL配置变量? [英] How do I persist MySQL configuration variables in CloudSQL?

查看:78
本文介绍了如何在CloudSQL中保留MySQL配置变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎找不到任何有关如何在Google的CloudSQL中设置和保留MySQL配置变量的说明或示例.

I can't seem to find any instructions or examples on how to set and persist MySQL configuration variables in Google's CloudSQL.

我遇到的具体问题是,默认情况下,交互式会话会挂起8个小时,如果我与交互式会话断开连接,则该线程将保持打开状态,然后更新事务块,直到我杀死该线程为止.

The specific problem I'm encountering is that interactive sessions hang around for 8 hours by default and, if I get disconnected from an interactive session the thread remains open and then update transactions block until I kill the thread.

我发现的解决方案就是这个:

set global interactive_timeout=300;

五分钟后终止交互式会话.

To terminate the interactive session after five minutes.

但是该解决方案不起作用,因为出现错误:

But that solution does not work because I get the error:

错误1227(42000):访问被拒绝;您需要(至少其中一种)SUPER权限才能进行此操作

ERROR 1227 (42000): Access denied; you need (at least one of) the SUPER privilege(s) for this operation

添加超级特权失败,如下所示:

And adding super privileges fails like this:

mysql> GRANT SUPER ON *.* TO 'root'@'%' IDENTIFIED BY '<pwd>';
ERROR 1045 (28000): Access denied for user 'root'@'%' (using password: YES)

因此,似乎Cloud SQL实例的root用户没有足够的权限来设置全局变量.

So it seems the root user of the Cloud SQL instance does not have sufficient privileges to set global variables.

另外,我不知道如何保留该设置,以便在重新启动服务器时将其保留在原处.

Separately, I can't figure out how to persist that setting so that it will remain in place if the server is restarted.

我看过使用:

gcloud sql instances patch

但它似乎无法修补这些设置.

but it does not seem to have the ability to patch these settings.

任何帮助将不胜感激.

推荐答案

您现在可以在实例上设置数量有限的标志,请参见

You can now set a limited number of flags on your instance, see this Google doc.

不幸的是,这不包括 interactive_timeout 标志.

Unfortunately this does not include the interactive_timeout flag.

原始答案

无法使用Cloud Console或gcloud实用程序在Cloud SQL上设置全局变量.

It is not possible to set global variables on Cloud SQL with either the Cloud Console or gcloud utility.

而且Cloud SQL不支持授予 SUPER 特权请参阅本页底部.

And Cloud SQL does not support granting SUPER privileges see the bottom of this page .

但是在这个类似的问题中 Google Cloud SQL max-allowed-packet 一位Google员工回答说,您可以通过cloud-sql@google.com用项目和实例名称通过电子邮件发送给他们,他们可以为您配置该设置,以便他们可以为您设置Interactive_timeout.

However in this similar question Google Cloud SQL max-allowed-packet a Googler has answered saying that you can email them at cloud-sql@google.com with the project and instance name and they can configure that settings for you, so they may be able to set interactive_timeout for you.

这篇关于如何在CloudSQL中保留MySQL配置变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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