简体   繁体   English

无法在MySql的Azure数据库上创建存储过程

[英]Not able to create stored procedure on Azure Database for MySql

I have configured an Azure Database for MySQL and able to connect to it successfully. 我已经为MySQL配置了Azure数据库,并且能够成功连接到它。 I am also able to create New Tables and run queries on those tables but when creating a stored procedure, I am getting below error:- 我也能够创建新表并在这些表上运行查询,但是在创建存储过程时,出现以下错误:-

Er 1227. Access error Code: denied; you need (at least one of) the SUPER privilege(s) for this operation

Example procedures is tried is 示例程序尝试的是

DELIMITER $$

CREATE DEFINER='user'@'server'

PROCEDURE `sp_getComplaintsByBranchCode`(
  in branchCode Varchar(50),
  in companyCode Varchar(50),
  in RowsPerPage INT, 
  in pageNumber INT
)
NOT DETERMINISTIC NO SQL SQL SECURITY DEFINER
BEGIN
DECLARE pageFrom INT;
DECLARE rowLimit INT;
DECLARE companyid varchar(50);
DECLARE branchid varchar(50);
DECLARE offval INT;

SET pageFrom = pageNumber;
SET rowLimit = RowsPerPage;
SET branchid = branchCode;
SET companyid = companyCode;
SET offval = ((pageFrom-1) * rowLimit);

select * from complaints c
WHERE c.branchCode = branchid AND c.fb_companyID = companyid
ORDER BY added_on DESC limit rowLimit OFFSET offval;

END

I checked user permissions and the database admin user which got created during initial setup doesn't have super privileges. 我检查了用户权限,并且在初始设置过程中创建的数据库管理员用户没有超级特权。 The only user with super privileges is "azure_superuser" and I don't have connection password for it. 唯一具有超级特权的用户是“ azure_superuser”,我没有连接密码。 Please help me with below issues or point me to some references which can help:- 请帮助我解决以下问题,或为我提供一些参考资料,这对您有帮助:-

1) How to connect to 'azure_superuser' OR 2) How to grant superuser privileges to the admin user I have without login as root user. 1)如何连接到“ azure_superuser”或2)如何将超级用户特权授予我具有的管理员用户,而无需以root用户身份登录。 3) How to enable a user with super_priviledge as 'N' to create stored procedures in Azure database for MySQL. 3)如何使以super_priviledge为“ N”的用户在Azure数据库中为MySQL创建存储过程。

Some references:- 一些参考:

Stack Overflow Question 堆栈溢出问题

Github Github上

Please remove DEFINER clause from the statement. 请从语句中删除DEFINER子句。 It should work. 它应该工作。

The SUPER privilege is not supported on Azure Database for MySQL. MySQL的Azure数据库上不支持SUPER特权。 The closest you can get is to create another admin level user with the same rights as the server admin you created to do this you can run: 您可以得到的最接近的结果是创建另一个管理员级别的用户,该用户具有与您创建的服务器管理员相同的权限,可以执行以下操作:

CREATE USER 'testuser'@'%' <span>IDENTIFIED </span>BY 'your_password_here';

GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER ON *.* TO 'testuser'@'%' WITH GRANT OPTION;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM