Can MySQL server send a "server started/running" signal to a remote server? I have a MySQL 8 server on a virtual machine. I'd like to start it up when another server wants to communicate with it, and shut it down some time after there hasn't been any connections or queries.
Right now I'm polling the VM to get it somewhat working, but there's gotta be a better way.
I read the MySQL docs on handling Unix signals, but there isn't a &quot;startup&quot; type signal.
I also read about MySQL events, but those seem to be limited to operations within the database like SQL queries.
Does MySQL have a way to push events to a remote server on startup, shutdown, error, etc.?
It's probably possible to achieve in a script on the OS, and then send a curl request to the remote server with appropriate info, but MySQL's a big software and I'm curious if this functionality is hidden somewhere in it.
Such a feature cannot be in mysqld in the cloud.
In order not to pay for a cloud VM, it must be totally down.  That means that communication with it must be preceded by restarting your image.  Only then is mysqld awake.  At that point, it is ready to receive connections.  (And you must &quot;connect&quot; before doing &quot;insert&quot; or whatever you need to do.)
So, your &quot;it's probably possible ...&quot; paragraph is the approach to take.
To add to the complexity, there is probably no easy way to &quot;automatically shut down&quot; the VM after an idle period.  Consider having your &quot;restart&quot; script wait a few minutes, then shutdown.  (Where &quot;a few minutes&quot; is tuned to accommodate your typical activity time.)
For security reasons, MySQL deliberately has no built-in way to communicate with the rest of the world.  (A common request is to send an email based on some data change.)
Another thing to look into -- a proxy between your clients and the VM-MySQL server.  The proxy would live on the client machine(s).  It might be able to orchestrate the startup.  (There are many Proxy products out there; they are aimed at other things -- HA, sharding, routing, load balancing, etc.)