The MariaDB server can write all SQL queries to a file for auditing or debugging purpose. It is called General Query Log. By default, this feature is not enabled.
Here is the process to enable query logs in MariaDB:
Step 1: Open MariaDB Config File
Open your MariaDB configuration file in a text editor. The file’s location may vary depending on the system, but some common locations are /etc/my.cnf or /etc/mysql/my.cnf.
Step 2: Add Settings to the Config File
Scroll to the [mysqld] section in the file and add these settings:
In the above settings, `general_log = on` enables the general query log, and `general_log_file` sets the path to the log file.
Step 3: Save and Close the File
Use CTRL+X to close the file and then Y to save the changes.
Step 4: Create the Log File
sudo touch /var/log/mysql/query.logStep 5: Change the Ownership of the Log File
sudo chown mysql:mysql /var/log/mysql/query.logStep 6: Restart MariaDB Server
Finally, apply these changes by restarting your MariaDB server. The command for this action could be one of the following, depending on your system:
Now, your MariaDB server should log all SQL queries to the specified file. You can view the contents of the log file using a command like cat or tail.
sudo cat /var/log/mysql/query.logKeep in mind that enabling the general query log may have some performance impact on a busy database server, as it will be writing all queries to a log file.