First, Keep in mind that this log file can grow very large on a busy server.
For mysql < 5.1.29:
In order to enable the query log, put this in /etc/my.cnf in the [mysqld] section
log = /path/to/query.log
Also, to enable it from the MySQL console
SET general_log = 1;
For MySQL 5.1.29+
With MySQL 5.1.29+, the log option is deprecated. To determine the log file and enable logging, use this in my.cnf in the [mysqld] section:
general_log_file = /path/to/query.log
general_log = 1
On the other hand, for turning on logging from the MySQL console (should further specify the log file location anyhow, or find the default location):
SET global general_log = 1;
Additionally, note that there are further options to log only slow queries or those which do not use indexes.
Willing to Learn SQL? Come and Join the SQL Certification course by Intellipaat.