How did I fix «Status: "Server shutdown complete"» / «Error: 9 (Bad file descriptor)» in MySQL for a custom `log_error` location?

The solution is to adjust AppArmor settings for MySQL.