MySQL Stored Procedure Permissions(MySQL 存储过程权限)
问题描述
我试图授予用户在 MySQL 数据库上的存储过程级别运行存储过程的权限,而不是允许用户执行数据库中的任何存储过程.我试图执行以下代码:
I am trying to give a user permission to run a stored procedure at the stored procedure level on a MySQL Database rather than allowing a user to execute any stored procedure in the database. I was trying to execute the following code:
GRANT EXECUTE ON myDB.spName TO 'TestUser'@'localhost';
但我不断收到以下错误:非法的 GRANT/REVOKE 命令,请查阅手册以了解可以使用哪些权限.
But i keep getting the following error: Illegal GRANT/REVOKE command, please consult the manual to see which privileges can be used.
我尝试将其更改为以下内容:
I tried changing it to the following:
GRANT EXECUTE ON PROCEDURE myDB.spName TO 'TestUser'@'localhost';
并且我收到一个不同的错误说明:
无法在用户表中找到任何匹配的行.
And i get a different error stating:
Cant find any matching rows in the user table.
我不知道哪里出错了?
同样在 MySQL Workbench 上,我似乎看不到任何通过 GUI 在存储过程级别授予权限的方法.这是正确的还是我遗漏了什么?
Also on the MySQL Workbench I can not seem to see any way to grant permissions at the stored procedure level via the GUI. Is this correct or am I missing something?
提前致谢.
推荐答案
您的第二次尝试是正确的方法:
Your second attempt is the right approach:
GRANT EXECUTE ON PROCEDURE myDB.spName TO 'TestUser'@'localhost';
但如果这不起作用,请验证...
but if that is not working, verify ...
a) 您(您从中运行所有这些命令的用户)拥有授予权限[即具有授予选项].如果您是根用户,那么您就拥有授予权限.
a) you (the user from which you are running all these command) have grant rights [i.e WITH GRANT OPTION]. If you are root, then you have grant rights.
b) 您授予执行权限的用户存在,例如
b) the user exists to which you are granting execute permission e.g.
select user from mysql.user where user like 'test%';
如果没有,则创建用户,例如
If not, then create the user e.g.
CREATE USER 'TestUser'@'localhost' IDENTIFIED BY 'passwordxxxx';
#depending on your needs
GRANT SELECT,DELETE,UPDATE PRIVILEGES ON myDb.* TO 'TestUser'@'localhost';
希望这有帮助:)
这篇关于MySQL 存储过程权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:MySQL 存储过程权限
基础教程推荐
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- SQL Server 2016更改对象所有者 2022-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01