lnmp turns off mysql logging to protect hard disk space

  • 2020-06-07 05:26:25
  • OfStack

Let's share 1 of the ways to turn off the mysql log

Mysql installed in LNMP1 key pack turns on Mysql logging by default. If the website reads and writes to the database frequently, it may generate a large number of logs and take up disk space. In addition, it may cause VPS's idle disk space to be full and the database cannot be started.

The path for this tutorial applies to the LNMP1 key installation package environment, but other environments should be used as appropriate.

If you need to close, do the following:

1. Modify the file configuration

Modify /etc/ my.cnf to find the following characters

log-bin=mysql-bin
binlog_format=mixedbash

Comment these two lines as follows:

#log-bin=mysql-bin
#binlog_format=mixedbash

Add the # comment before the two fields and save the file.

2. Restart Mysql to make it effective

service mysqld restartbashSSH

Execute the above command and restart Mysql for the comments to take effect

3. Delete the previously generated logs

1) Landing on MYSQL

/usr/local/mysql/bin/mysql -u root -pbashSSH

After executing the above command and entering the password, enter MYSQL command line mode.

2) Reset the account
reset qzkyl;
Please change #qzkyl to the target database name

The following is the supplement:

Today I found out that the VPS hard drive is almost full. The first response was: It must be something with a log file, because I've had a similar experience with WINDOWS before.

Analyze 1, find the reason: MYSQL log file.

You can also use the following command to look up 1 (if not LNMP, the path may be different) :


du -h --max-depth=1 /usr/local/mysql/var/*

If you see a lot of large files called ES77en-ES78en.000014, you also need to close the log files because you don't know when they will fill your VPS hard drive.

Use WINSCP to delete these files.

How to close:


vi /etc/my.cnf

Find:


log-bin=mysql-bin
binlog_format=mixed
[code]
Comment out these two lines and add them in front of them #
And save it.
Finally restart with the following instructions LNMP . Call it a day.
[code]
/root/lnmp restart


Related articles: