For example, if you want to log all queries that are slower than one second, you can execute:
mysql> SET GLOBAL long_query_time = 1;
To make the changes persistent across restarts use:
mysql> SET PERSIST long_query_time = 1;Query OK, 0 rows affected (0.01 sec)
mysql> SET @@persist.long_query_time = 1;Query OK, 0 rows affected (0.00 sec)
The persisted global system variable settings are stored in mysqld-auto.cnf which is located in data directory.
Suppose you want to log queries only for this session and not for all the connections. You can use the following command:
mysql> SET SESSION long_query_time = 1;