Event between server and clients Is it possible to achieve that a client sends an event to the MySQL server and the server sends this event to all clients? How can clients get this event?

Sometimes a user sends some data to another user that use the same application by setting the second user_id in the working table.

I want to tell the second user immediately what happens.
There is no feature to do this but it can be done with a slightly hack method of making a sleeping connection and killing it when the event occurs.

The client submits a long running sleep query:

SELECT /* WAITING_FOR_EVENT */ SLEEP(9999);


The client will now sit waiting for the query to return.

Now to signal the event, you just kill the thread. This could be set off by another client, a trigger, a scheduled event, etc.

SELECT * FROM information_schema.processlist WHERE `INFO` LIKE '%WAITING_FOR_EVENT%';


This gives the process id that is running the sleep query. Then simply kill it with the KILL command.

The client will see it was interupted and now knows the event has been triggered.

You can have multiple listeners using this method but cannot pass any data back to the listening client, only signal an event has occurred.