By default, log files are enabled for MySQL/MariaDB installed in the one-click LNMP installation package. If data operations are frequent, a large number of logs are generated, generate a mysql-bin.0000 * similar file under/usr/local/mysql/var/or/usr/local/mariadb/var/, which is usually dozens of MB to several GB, even worse, it will eat the entire hard disk space, and mysql/MariaDB will never be able to start or report an error.
How do I disable the log function of MySQL?
Delete log:
Run the following command in Mysql:
/Usr/local/mysql/bin/mysql-u root-p
MariaDB executes the following command:
/Usr/local/mariadb/bin/mysql-u root-p
Enter the password to log on and then execute:
MySQL
Reset master;
Press enter and enter quit to exit mysql/MariaDB command mode.
As shown in the following figure:
Permanently disable MySQL logs: modify the/etc/my. cnf file and find
INI
Log-bin = mysql-bin
Binlog_format = mixed
Add # to the front of the two lines, comment out the lines, and then run/etc/init. d/mysql restart or/etc/init. d/mariadb restart.
If you really want to keep the log, you can add expire_logs_days = 10 to/etc/my. cnf and then restart mysql, so that the log will be automatically cleared in 10 days.
This article takes the environment where an LNMP installation package is installed as an example. Except the Restart command and the configuration file path may be slightly different, the other is the same.