Google CloudSQL 第二代创建函数不工作
Google CloudSQL 2nd Generation create Function not working
对于 Google CloudSQL 第二代实例,启用了故障转移复制。之后,当尝试导入数据库时,它不允许创建过程。收到以下错误。
Error Code: 1419. You do not have the SUPER privilege and binary
logging is enabled (you might want to use the less safe
log_bin_trust_function_creators variable)
具有故障转移功能的 CloudSQL 是否真的不支持功能?
示例执行查询
DELIMITER ;;
CREATE FUNCTION `stutzen`(amount INT) RETURNS int(11)
DETERMINISTIC
BEGIN
DECLARE charges FLOAT DEFAULT 1.0;
SELECT valuesettings INTO charges FROM dreamer_tbl WHERE namesettings='stutzen.co';
RETURN FLOOR((amount / 100) * charges) ;
END ;;
DELIMITER ;
这不是存储过程,而是用户定义函数。
您需要将此 UDF 重写为存储过程,这样才行。
Google Cloud SQL 支持存储过程和函数。
在您的情况下,问题似乎是您试图导入一个 sql 文件,该文件具有某种需要 SUPER 权限的例程,而这是不允许的。
我尝试使用 SET GLOBAL log_bin_trust_function_creators,它应该允许在没有 SUPER 权限的情况下创建函数,但在 Cloud SQL 中也不允许设置该变量。设置它需要 SUPER 权限。
你应该运行:
gcloud sql instances patch [INSTANCE_NAME] --database-flags
log_bin_trust_function_creators=ON
如前所述here
您只需将 'log_bin_trust_function_creators' 设置为 ON
要执行此操作,请打开 https://console.cloud.google.com
Select SQL
Select 你的实例
Select 编辑
DB 信号
添加:
log_bin_trust_function_creators 在
general_log 在
保存
对于 Google CloudSQL 第二代实例,启用了故障转移复制。之后,当尝试导入数据库时,它不允许创建过程。收到以下错误。
Error Code: 1419. You do not have the SUPER privilege and binary logging is enabled (you might want to use the less safe log_bin_trust_function_creators variable)
具有故障转移功能的 CloudSQL 是否真的不支持功能?
示例执行查询
DELIMITER ;;
CREATE FUNCTION `stutzen`(amount INT) RETURNS int(11)
DETERMINISTIC
BEGIN
DECLARE charges FLOAT DEFAULT 1.0;
SELECT valuesettings INTO charges FROM dreamer_tbl WHERE namesettings='stutzen.co';
RETURN FLOOR((amount / 100) * charges) ;
END ;;
DELIMITER ;
这不是存储过程,而是用户定义函数。 您需要将此 UDF 重写为存储过程,这样才行。
Google Cloud SQL 支持存储过程和函数。
在您的情况下,问题似乎是您试图导入一个 sql 文件,该文件具有某种需要 SUPER 权限的例程,而这是不允许的。
我尝试使用 SET GLOBAL log_bin_trust_function_creators,它应该允许在没有 SUPER 权限的情况下创建函数,但在 Cloud SQL 中也不允许设置该变量。设置它需要 SUPER 权限。
你应该运行:
gcloud sql instances patch [INSTANCE_NAME] --database-flags
log_bin_trust_function_creators=ON
如前所述here
您只需将 'log_bin_trust_function_creators' 设置为 ON
要执行此操作,请打开 https://console.cloud.google.com
Select SQL
Select 你的实例
Select 编辑
DB 信号
添加: log_bin_trust_function_creators 在
general_log 在
保存