Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is `definer` required when creating a stored procedure?

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

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

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?

like image 358
Xorty Avatar asked Apr 19 '10 09:04

Xorty


1 Answers

As stated in MySQL documentation here

CREATE [DEFINER = { user | CURRENT_USER }] PROCEDURE sp_name ([proc_parameter[,...]]) [characteristic ...] routine_body 

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

like image 160
maid450 Avatar answered Sep 21 '22 17:09

maid450