MySQL logs are files that record various information about your database activity, such as sessions, queries, errors, and performance. While these logs can be useful for debugging or monitoring purposes, they can also consume a lot of disk space over time and affect your website performance.

If you want to disable MySQL logging completely, you will need to edit the configuration file to comment out the lines that enable the different types of logs. Then, you will need to restart the MySQL service to apply the changes.

Here are the steps to follow:

  1. Log in to your server as root via SSH.
  2. Open the my.cnf file with a text editor, such as nano
nano /etc/mysql/mariadb.conf.d/50-server.cnf

Note: If you can’t find the config file in the above directory, you may need to look for my.cnf in the /etc/mysql directory instead.

  1. Locate the lines that start with general_log, slow_query_log, or log_bin, and add a # symbol at the beginning of each line to comment them out. For example:
#general_log_file = /var/log/mysql/mysql.log#general_log = 1
#slow_query_log_file = /var/log/mysql/mariadb-slow.log
#log_bin = /var/log/mysql/mariadb-bin
#log_bin_index = /var/log/mysql/mariadb-bin.index
MySQL server configuration in Uvuntu Server
  1. Save and exit the file by pressing Ctrl + O, Enter, and then Ctrl + X.
  2. Restart the MySQL service using the following command:
service mysql restart

That’s it! You have successfully disabled MySQL logging on your server. You can also delete the existing log files from the /var/log/mysql/ directory if you don’t need them anymore.