MySQL 权限——即使使用“CREATE ROUTINE”也无法创建函数。授予
当连接到我的服务器(从另一台机器)时,我
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为有一个
CREATE FUNCTION
与CREATE ROUTINE
是分开的。但无论哪种方式,因为看起来你的用户无论如何都有 100% 完全访问权限,所以你可以这样做:但是我会注意到,将 '%' 设置为 'localhost' 并仅以这种方式从本地访问数据库会更好机器(或至少是受信任的 IP)。缺乏安全性可能会给您带来麻烦。
绝对不要使用此用户/密码从 Web 脚本连接到数据库!
编辑
我忘记了:例程和函数必须全局授予。添加 . 尝试将授权添加到表本身,这就是它不起作用的原因。尝试:
这里有一个更长的描述: http://dev.mysql .com/doc/refman/5.0/en/grant.html
I think there is a
CREATE FUNCTION
that is separate fromCREATE ROUTINE
. But either way, since it looks like your user has 100% full access anyway you could do: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:
There's a longer description of it here: http://dev.mysql.com/doc/refman/5.0/en/grant.html