创建存储过程时是否需要`definer`? [英] Is `definer` required when creating a stored procedure?

查看:2464
本文介绍了创建存储过程时是否需要`definer`?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将所有MySQL过程编写为root@localhost:

I've written all of MySQL procedures as root@localhost:

CREATE DEFINER=`root`@`localhost` PROCEDURE `p_add_user`(...)

问题是,当部署到另一台服务器时,我必须用当前用户替换root并用当前IP替换localhost,这很烦人.

Trouble is, when deploying to another server, I have to replace root with current user and replace localhost with current IP, which is annoying.

有什么方法可以编写过程,以便希望使用我的数据库和过程的人不必修改每个过程的定义器?

Is there any way to write procedures so that someone who wants to use my database and procedures would not have to modify the definer of each procedure?

推荐答案

如MySQL文档因此,DEFINER部分不是强制性的,只是CREATE PROCEDURE应该起作用.

So, the DEFINER part is not mandatory, just CREATE PROCEDURE should work.

这篇关于创建存储过程时是否需要`definer`?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆