# Bug: Explicit definer is ignored when I create an event

**URL:** <https://forums.percona.com/t/bug-explicit-definer-is-ignored-when-i-create-an-event/7565>\
**Category:** Percona Server for MySQL 5.7\
**Created:** [April 22, 2020, 7:33am UTC](https://forums.percona.com/t/bug-explicit-definer-is-ignored-when-i-create-an-event/7565 "2020-04-22T07:33:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrew\_soloshko](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@andrew\_soloshko](https://forums.percona.com/u/andrew_soloshko)\
**Post date:** [April 22, 2020, 7:33am UTC](https://forums.percona.com/t/bug-explicit-definer-is-ignored-when-i-create-an-event/7565/1 "2020-04-22T07:33:54Z")

</div>

Hi,I logged in to Percona MySQL5.7 (version 5.7.24-26-log Percona Server (GPL), Release 26, Revision c8fe767) as user **‘andrew’@‘localhost’.**  
And I need to create an event with DEFINER = ‘root’@‘localhost’, and I am executing

```auto
CREATE DEFINER = 'root'@'localhost'
EVENT ps_helper.event1
ON SCHEDULE EVERY '1' DAY
STARTS '2020-04-22 10:12:42'
DO 
BEGIN
-- some code is here
END;
ALTER EVENT ps_helper.event1 ENABLE<br>

```

but when I execute **CREATE EVENT event1** then I get:

```auto
CREATE DEFINER = 'andrew'@'localhost'
EVENT ps_helper.event1
ON SCHEDULE EVERY '1' DAY
STARTS '2020-04-22 10:12:42'
DO 
BEGIN
-- some code is here
END;
ALTER EVENT ps_helper.event1 ENABLE

```

As you can see MySql replaced definer from **‘root’@‘localhost’** to my current user **‘andrew’@‘localhost’.** The same issue happens in Percona MySql8 (version 8.0.18-9 Percona Server (GPL), Release 9, Revision 53e606f)Why MySql ignores definer when I create the event?   
And how to force MySql to use definer I want?Are there any plans to fix this bug in any nearest version?

---

<div class="post-metadata">

**Author:** ![lorraine.pocklington](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/lorraine.pocklington/32/37_2.png) [@lorraine.pocklington](https://forums.percona.com/u/lorraine.pocklington)\
**Post date:** [April 23, 2020, 4:58am UTC](https://forums.percona.com/t/bug-explicit-definer-is-ignored-when-i-create-an-event/7565/2 "2020-04-23T04:58:37Z")

</div>

Can I just make sure with you that the user root has the right privilege to run the event? I found this on StackOverflow (see 7th answer) so just thought we should cover that off first. Thanks!&nbsp;[https://stackoverflow.com/questions/16767923/mysql-event-not-working](https://stackoverflow.com/questions/16767923/mysql-event-not-working "Link: https://stackoverflow.com/questions/16767923/mysql-event-not-working")

---

<div class="post-metadata">

**Author:** ![andrew\_soloshko](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@andrew\_soloshko](https://forums.percona.com/u/andrew_soloshko)\
**Post date:** [April 23, 2020, 6:58am UTC](https://forums.percona.com/t/bug-explicit-definer-is-ignored-when-i-create-an-event/7565/3 "2020-04-23T06:58:44Z")

</div>

Yes, root has the right privilege to run the event.After more testing, I have identified that the CREATE EVENT query (mentioned above) works correctly with definer.And the definer is replaced by the second ALTER query:

```auto
ALTER EVENT ps_helper.event1 ENABLE

```

Possibly this is not a bug, and I must always explicitly add definer to ALTER queries as well like this:

```auto
ALTER DEFINER = 'root'@'localhost' EVENT ps_helper.event1 ENABLE

```

---

<div class="post-metadata">

**Author:** ![lorraine.pocklington](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/lorraine.pocklington/32/37_2.png) [@lorraine.pocklington](https://forums.percona.com/u/lorraine.pocklington)\
**Post date:** [April 27, 2020, 10:01am UTC](https://forums.percona.com/t/bug-explicit-definer-is-ignored-when-i-create-an-event/7565/4 "2020-04-27T10:01:30Z")

</div>

Thanks for the update, that’s likely to help others in the future too.
