Reputation: 2766
In the /var/log/mysql
I found that are many large files
-rw-rw---- 1 mysql adm 104875724 Nov 16 2016 mysql-bin.002982
-rw-rw---- 1 mysql adm 104900467 Nov 16 2016 mysql-bin.002983
...............
-rw-rw---- 1 mysql adm 104919093 Nov 23 2016 mysql-bin.003118
-rw-rw---- 1 mysql adm 104857817 Nov 23 2016 mysql-bin.003119
-rw-rw---- 1 mysql adm 104858056 Nov 23 2016 mysql-bin.003120
-rw-rw---- 1 mysql adm 9184221 Nov 23 2016 mysql-bin.003121
-rw-rw---- 1 mysql adm 104907549 Nov 23 2016 mysql-bin.003122
......
-rw-rw---- 1 mysql adm 6272 Nov 25 2016 mysql-bin.index
Can I delete them?
Update
I don't use a replication for the database
Upvotes: 4
Views: 9816
Reputation: 589
better not do it manually, you can do it through mysql.
PURGE BINARY LOGS TO 'binlogname';
PURGE BINARY LOGS BEFORE 'datetimestamp';`
for example to delete everything before a week ago run:
PURGE BINARY LOGS BEFORE DATE(NOW() - INTERVAL 3 DAY) + INTERVAL 0 SECOND;
or (even better) edit the my.cnf
and set this parameter
[mysqld]
expire_logs_days=7
Upvotes: 8
Reputation: 116
These large files are MYSQL BINARY LOG, stores query event such as add, delete and update in a very details way. The Binary Log is used for two main purposes:
There are several ways to remove or clean up MySQL Binary Log, it’s not recommend to clean up the file manually, you need to use PURGE BINARY LOGS statement to safely purge binary log files:
SHOW SLAVE STATUS
to check which log file it is reading.SHOW BINARY LOGS
.Since you have not set up a backup, do the following:
you can also remove the binary older than a specific date, such as 2019-04-02 22:46:26,
PURGE BINARY LOGS TO 'mysql-bin.010';
PURGE BINARY LOGS BEFORE '2019-04-02 22:46:26';
PURGE BINARY LOGS statement structure:
PURGE { BINARY | MASTER } LOGS {
TO 'log_name'
| BEFORE datetime_expr
}
It's directly from the official website
Upvotes: 2
Reputation: 21
You can also delete them with a 1 liner.
It deletes all binary logs safely through MySQL except for the ones you are using in your current session.
purge binary logs before curdate();
Upvotes: 1