首页 > 解决方案 > 无法在 Azure mySQL 中创建函数/存储过程

问题描述

我刚刚使用 Azure 设置了一个 mysql 数据库,我正在使用 Navicat 连接到它,一切正常。我现在正在尝试创建一些函数和存储过程,但出现超级用户错误:

您没有超级权限并且启用了二进制日志记录(您可能希望使用不太安全的 log_bin_trust_function_creators 变量)> 时间:0.027s

这是我其中之一的代码:

CREATE function `triggertradersazure`.`sf_entity_active_sub`(`p_entity_id` INT) 
returns INT(11) 
DETERMINISTIC 
begin 
  IF EXISTS (SELECT 1 
             FROM   tbl_stripe_customer_link_sub sc 
                    JOIN tbl_stripe_sub_payments ss 
                      ON sc.stripe_customer_id = ss.stripe_customer_id 
                         AND ss.stripe_subscription_id = 
                             sc.stripe_subscription_id 
             WHERE  active = 'Y' 
                    AND entity_id = p_entity_id) THEN 
    RETURN 1; 
  ELSE 
    RETURN 0; 
  end IF; 
end; 

用户信息来自mql.user

INSERT INTO `mysql`.`user` 
            (`host`, `user`, `password`, `select_priv`, `insert_priv`, `update_priv`, `delete_priv`, `create_priv`, `drop_priv`, `reload_priv`, `shutdown_priv`, `process_priv`, `file_priv`, `grant_priv`, `references_priv`, `index_priv`, `alter_priv`, `show_db_priv`, `super_priv`, `create_tmp_table_priv`, `lock_tables_priv`, `execute_priv`, `repl_slave_priv`, `repl_client_priv`, `create_view_priv`, `show_view_priv`, `create_routine_priv`, `alter_routine_priv`, `create_user_priv`, `event_priv`, `trigger_priv`, `create_tablespace_priv`, `ssl_type`, `ssl_cipher`, `x509_issuer`, `x509_subject`, `max_questions`, `max_updates`, `max_connections`, `max_user_connections`, `plugin`, `authentication_string`, `password_expired`) 
VALUES      ('%', 'triggertraders', '*', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'N', 'Y', 'N', 'Y', 'Y', 'Y', 'Y', 'Y', 'N', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'N', '', '', '', '', 0, 0, 0, 0, 'mysql_native_password', '', 'N'); 

此用户没有超级用户,但我不需要它,Azure 不允许它?

目前不知道该怎么办。我的功能有

`CREATE DEFINER = `tiggertraders`@`ip`

我删除了它,因为这是为了解决问题。

任何帮助都会很棒,

谢谢,

标签: mysqlazure

解决方案


我必须使用 Azure 中的 log_bin_trust_function_creators 服务器属性来允许这样做 - 如下所示:

在此处输入图像描述


推荐阅读