How can I move an existing MySQL event to another database?

MySQLMySQLi Database

It can be done with the help of ALTER EVENT statement too. We need to use the combination of database name and event name along with the RENAME keyword. To illustrate it we are having the following example in which we are moving the event named ‘hello_renamed’ from ‘query’ database to ‘tutorial’ database −


mysql> ALTER EVENT query.hello_renamed RENAME to tutorials.hello_renamed;
Query OK, 0 rows affected (0.00 sec)

To confirm that event has been moved to database ‘tutorials’ we can try to delete the event with an old name, MySQL will throw an error as follows −

mysql> DROP event hello_renamed;
ERROR 1539 (HY000): Unknown event 'hello_renamed'
Published on 22-Feb-2018 12:43:12