During busy periods, the new server and app will be renewed. In addition, many configurations will be changed when the company moves at the end of the month.
In the morning, when you do not want to change the dns via telnet, it is found that the MySQL daily quota is very large... It's strange that I have changed all settings ..
Later, it was found that this machine was brought by a subsidiary .... In the past, the configurations were not completed. Let's sort them out today and share them with you.
1. Clear the current BINLOG first:
$ Mysql-uroot-p
Login using secret and secret
Mysql>SHOW MASTER LOGS; Begin indicates LOG first
+ ------------------------ + ------------ +
| Log_name | File_size |
+ ------------------------ + ------------ +
| Mysql-bin.000001 | 74149684 |
| Mysql-bin.000002 | 73741963 |
| Mysql-bin.000003 | 73742026 |
| Mysql-bin.000004 | 73741905 |
:
| Mysql-bin.000065 | 3273742014 |
| Mysql-bin.000066 | 98746708 |
+ ------------------------ + ------------ +
66 rows in set (0.00 sec)
Except LOG
Except for a certain day's hosts file:
Mysql> purge master logs to 'mysql-bin.000066 ';
Except all the day before the first day:
Mysql> purge binary logs before DATE_SUB (NOW (), INTERVAL7DAY );
Except all day-olds before a certain day
Mysql> purge master logs before '2017-03-19 00:00:00 ';
When the division is complete, set it to your own.
In the/etc/my. cnf file, locate the mysql configuration file:
# Here follows entries for some specific programs
# The MySQL server
[Mysqld]
Default-character-set = utf8
Port = 3306
Socket =/tmp/mysql. sock
... ...
# Replication Master Server (default)
# Binary logging is required for replication
LOg-bin = mysql-bin
... ...
Then, add the following content:
Expire_logs_days = 30(Number of days in which the BINLOG is automatically deleted)
Modify my. cnf and then restart MySQL !!! Note:
You can directly modify the MySQL variable volume environment:
$ Mysql-uroot-p
Mysql> SETGLOBALExpire_logs_days = 30;|
This does not require restart
Remember not to confirm after modification:
Mysql>Show global variablesLike 'expire % ';
+ ------------------ + ------- +
| Variable_name | Value |
+ ------------------ + ------- +
| Expire_logs_days | 30 |
+ ------------------ + ------- +
Hope to help you