I would like to know how databases (like MySQL) are able to manage per user resources (like Oracle Database Resource Manager does) to be able to have users that may only get resources only when the database is mostly idle.
https://stackoverflow.com/questions/2418581/is-there-a-way-to-throttle-or-limit-resources-used-by-a-user-in-oracle
Depends.
Oracle has a Resource manager. SQL Server has one too (got one in 2008). Others (mySQL) dont.
how they work? Like every scheduler. Basically they measure performance counters and if one user / database goes over the allocated limit, his queries get slowed down (lower piority, normally) compared to the rest.
Note that "database is mostly idle" is REALLY a complicated question for databases. what you talk of? IO? CPU? Various queries have various bottlenecks.
MySQL, as far as I know, does not have a way to artificially limit resource usage by a user.
Usually you don't limit database access / queries directly, if you want to offer different service levels to customers you do that at another level (eg. you limit the number of processes answering web requests, this will indirectly limit resource usage on the whole backend infrastructure).
Users who do overuse a shared system to the point of creating problems to other users are usually detected by other means (eg. the system monitoring will alert you of an unresponsive system) and killed by hand. But that's not regular "scheduling" of normal operations, it's problem detection and response.
You can limit the amount of resources per user by alter commands
More info here: https://dev.mysql.com/doc/refman/8.0/en/user-resources.html