1. Turn on the parameters of the slow log to have a permanent effect. Add the following parameters in my.cnf.
[mysqld]
slow_query_log = 1
slow_query_log_file = /xxx/mysql-slow.log
long_query_time = 1
2. Normally this will fail to open, and the mysql log will report an error: Errcode: 13-Permission denied
mysqld: File '/var/log/mysql/mysql-slow.log' not found (Errcode: 13 - Permission denied)
2019-11-02T03:13:42.567891Z 0 [ERROR] Could not use /var/log/mysql/mysql-slow.log for logging (error 13 - Permission denied). Turning logging off for the server process. To turn it on again: fix the cause, then either restart the query logging by using "SET GLOBAL SLOW_QUERY_LOG=ON" or restart the MySQL server.
Cause: mysql does not have file read and write permissions
Solution: Secondly, permission denied is mainly due to directory permissions
chmod /xxx 777
chown -R mysql /xxx
chgrp -R mysql /xxx
3. Systemctl restart mysqld can restart mysql.