Close MySQL/MariaDB logs and delete mysql-bin.0000 * log files

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.