MySQL 权限——即使使用“CREATE ROUTINE”也无法创建函数。授予

发布于 2024-09-28 12:05:37 字数 626 浏览 6 评论 0原文

当连接到我的服务器(从另一台机器)时,我

Error Code: 1044 Access denied for user 'username'@'%' to database 'dbname'

尝试创建一个函数。但是当我查看我的权限时

SHOW GRANTS FOR CURRENT_USER;

,我

'GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE ROUTINE ON *.* TO ''username''@''%'' IDENTIFIED BY PASSWORD ''--stripped--'' WITH GRANT OPTION'

特别发现,这包括创建例程。为什么我不能创建一个函数?我怎样才能改变它,这样我就可以?

When connecting to my server (from a different machine) I get

Error Code: 1044 Access denied for user 'username'@'%' to database 'dbname'

when I try to create a function. But when I look at my permissions

SHOW GRANTS FOR CURRENT_USER;

I get

'GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE ROUTINE ON *.* TO ''username''@''%'' IDENTIFIED BY PASSWORD ''--stripped--'' WITH GRANT OPTION'

In particular, this includes CREATE ROUTINE. Why can't I make a function? How can I change it so I can?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回眸一笑 2024-10-05 12:05:38

我认为有一个 CREATE FUNCTIONCREATE ROUTINE 是分开的。但无论哪种方式,因为看起来你的用户无论如何都有 100% 完全访问权限,所以你可以这样做:

GRANT ALL PRIVILEGES ON *.* TO user@'%' INDENTIFIED BY 'password' WITH GRANT OPTION

但是我会注意到,将 '%' 设置为 'localhost' 并仅以这种方式从本地访问数据库会更好机器(或至少是受信任的 IP)。缺乏安全性可能会给您带来麻烦。

绝对不要使用此用户/密码从 Web 脚本连接到数据库!

编辑
我忘记了:例程和函数必须全局授予。添加 . 尝试将授权添加到表本身,这就是它不起作用的原因。尝试:

GRANT ALTER ROUTINE,CREATE ROUTINE, EXECUTE ON * TO user@'%' IDENTIFIED BY 'password'

这里有一个更长的描述: http://dev.mysql .com/doc/refman/5.0/en/grant.html

I think there is a CREATE FUNCTION that is separate from CREATE ROUTINE. But either way, since it looks like your user has 100% full access anyway you could do:

GRANT ALL PRIVILEGES ON *.* TO user@'%' INDENTIFIED BY 'password' WITH GRANT OPTION

However I would note it would be much better to set the '%' to 'localhost' and only access the database in this manner from a local machine (or at least a trusted IP). The lack of security with this could cause you trouble.

Definitely don't use this user/password to connect to the database from a web script!

Edit
I forgot: routines and functions have to be granted globally. Adding . tries to add the grant to the tables themselves which is why it doesn't work. Try:

GRANT ALTER ROUTINE,CREATE ROUTINE, EXECUTE ON * TO user@'%' IDENTIFIED BY 'password'

There's a longer description of it here: http://dev.mysql.com/doc/refman/5.0/en/grant.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文