Show all MySQL events that are running on my database?
Asked Answered
O

7

24

I have a MySQL database. I am running two MySQL EVENTs. I need to get rid of one. I don't remember it's name. What do I do?

Overcritical answered 29/1, 2012 at 22:55 Comment(1)
what about show processlist;? Is that what you're looking for?Ashjian
H
36

its simple SHOW EVENTS lists all of the events in the current schema

To see events for a specific schema, use the FROM clause. For example, to see events for the test schema, use the following statement:

SHOW EVENTS FROM test;
Hetman answered 29/1, 2012 at 23:1 Comment(0)
P
21

The information_schema.EVENTS table is where to start.

USE information_schema;

DESCRIBE EVENTS;
+----------------------+---------------+------+-----+---------------------+-------+
| Field                | Type          | Null | Key | Default             | Extra |
+----------------------+---------------+------+-----+---------------------+-------+
| EVENT_CATALOG        | varchar(64)   | YES  |     | NULL                |       |
| EVENT_SCHEMA         | varchar(64)   | NO   |     |                     |       |
| EVENT_NAME           | varchar(64)   | NO   |     |                     |       |
| DEFINER              | varchar(77)   | NO   |     |                     |       |
| TIME_ZONE            | varchar(64)   | NO   |     |                     |       |
| EVENT_BODY           | varchar(8)    | NO   |     |                     |       |
| EVENT_DEFINITION     | longtext      | NO   |     | NULL                |       |
| EVENT_TYPE           | varchar(9)    | NO   |     |                     |       |
| EXECUTE_AT           | datetime      | YES  |     | NULL                |       |
| INTERVAL_VALUE       | varchar(256)  | YES  |     | NULL                |       |
| INTERVAL_FIELD       | varchar(18)   | YES  |     | NULL                |       |
| SQL_MODE             | varchar(8192) | NO   |     |                     |       |
| STARTS               | datetime      | YES  |     | NULL                |       |
| ENDS                 | datetime      | YES  |     | NULL                |       |
| STATUS               | varchar(18)   | NO   |     |                     |       |
| ON_COMPLETION        | varchar(12)   | NO   |     |                     |       |
| CREATED              | datetime      | NO   |     | 0000-00-00 00:00:00 |       |
| LAST_ALTERED         | datetime      | NO   |     | 0000-00-00 00:00:00 |       |
| LAST_EXECUTED        | datetime      | YES  |     | NULL                |       |
| EVENT_COMMENT        | varchar(64)   | NO   |     |                     |       |
| ORIGINATOR           | bigint(10)    | NO   |     | 0                   |       |
| CHARACTER_SET_CLIENT | varchar(32)   | NO   |     |                     |       |
| COLLATION_CONNECTION | varchar(32)   | NO   |     |                     |       |
| DATABASE_COLLATION   | varchar(32)   | NO   |     |                     |       |
+----------------------+---------------+------+-----+---------------------+-------+

SELECT EVENT_NAME FROM EVENTS WHERE EVENT_SCHEMA = 'your_database_name';
Percolate answered 29/1, 2012 at 22:57 Comment(1)
To show all events: USE information_schema; DESCRIBE EVENTS; SELECT * FROM EVENTS; Dint
D
18

Show events with more details

SELECT * FROM information_schema.EVENTS
Dungdungan answered 11/10, 2019 at 15:6 Comment(1)
Best answer imhoMultifaceted
G
4
SHOW EVENTS\G

Which will bring you the list of all existing events. For Show Events Syntax: http://dev.mysql.com/doc/refman/5.1/en/show-events.html

Goldina answered 29/1, 2012 at 22:58 Comment(0)
N
3
show events;

will show all the events .

Network answered 9/2, 2017 at 7:9 Comment(0)
B
2

If you want to view all Event Schedulers from all databases in MySQL.

SELECT * FROM information_schema.EVENTS;

If you want to view all Event Schedulers from a specific database in MySQL.

SHOW EVENTS FROM 'your_database_name';

Event Scheduler Specific Query:

SELECT EVENT_DEFINITION
FROM information_schema.EVENTS
WHERE EVENT_NAME = 'your_event_name';

Database Specific Event Scheduler Query:

SELECT EVENT_DEFINITION
FROM information_schema.EVENTS
WHERE EVENT_NAME = 'your_event_name'
AND EVENT_SCHEMA = 'your_database_name';
Bathsheeb answered 15/5, 2023 at 7:12 Comment(0)
H
1

You can show all events with the SQL below. *The doc explains INFORMATION_SCHEMA.EVENTS table and I recommend to use \G which can show them more clearly and the SQL below can show more details than SHOW EVENTS which I explain last:

SELECT * FROM INFORMATION_SCHEMA.EVENTS;

Or:

SELECT * FROM INFORMATION_SCHEMA.EVENTS\G

And, you can show the events of apple database with the SQL below:

SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA = 'apple';

And, you can show the events running currently with the SQL below:

SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE STATUS = 'ENABLED';

And, you can show the events not running currently with the SQL below:

SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE STATUS = 'DISABLED';

And, you can show the events of apple database selecting apple database with USE. *The doc explains SHOW EVENTS and I recommend to use \G which can show them more clearly:

USE apple;
SHOW EVENTS;

Or:

USE apple;
SHOW EVENTS\G

Or:

USE apple;
SHOW EVENTS FROM apple;

Or:

USE apple;
SHOW EVENTS FROM apple\G

And, you can show the events running currently of apple database selecting apple database with USE:

USE apple;
SHOW EVENTS WHERE STATUS = 'ENABLED';

And, you can show the events not running currently of apple database selecting apple database with USE:

USE apple;
SHOW EVENTS WHERE STATUS = 'DISABLED';

And, you can show the events of orange database even if selecting apple database with USE:

USE apple;
SHOW EVENTS FROM orange;

And, you can show the events of apple database not selecting any one of databases with USE:

SHOW EVENTS FROM apple;

Be careful, if you run the SQL below not selecting any one of databases with USE:

SHOW EVENTS;

Then, there is the error below:

ERROR 1046 (3D000): No database selected

Harewood answered 7/11, 2023 at 3:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.