user936965
user936965

Reputation:

how to prevent mysql from createing mysql-bin.00000x files?

I see that mysql creates a lot of files that are named like mysql-bin.000001, mysql-bin.000002, mysql-bin.000003 etc. I've found here that my log_bin setting is "ON". I'm wondering how I can set this to off and if that's a smart thing to do. I've tried this: set log_bin = "OFF"; but it resulted to this: ERROR 1238 (HY000): Variable 'log_bin' is a read only variable

On multiple websites I've found this solution and changed it in "/etc/my.cnf":

Disable MySQL binlogging

If you are not replicating, you can disable binlogging by changing your my.ini or my.cnf file. Open your my.ini or /etc/my.cnf (/etc/mysql/my.cnf), enter:

# vi /etc/my.cnf

Find a line that reads "log_bin" and remove or comment it as follows:

# log_bin = /var/log/mysql/mysql-bin.log

You also need to remove or comment following lines:

# expire_logs_days = 10

# max_binlog_size = 100M

Close and save the file.

Finally, restart mysql server:

# service mysql restart

But this doesn't seem to have any affect at all. As far as I could find, these files mainly exist for replication, but I'm not replicating anything.

Upvotes: 2

Views: 6200

Answers (3)

61938388
61938388

Reputation: 73

I am using MySQL 8.4.2, and I have tried the above method, but I still cannot disable the binlog. I can only use ''' PURGE BINARY LOGS BEFORE DATE_SUB(CURDATE(), INTERVAL 2 DAY); ''' to clean up the logs every day

Upvotes: 0

user936965
user936965

Reputation:

Turned out that there was a setting server-id=1 that I had to remove. Problem is solved now.

Upvotes: 1

pala_
pala_

Reputation: 9010

If you want to disable the binary logging (necessary for replication, useful for recovery), do it by commenting out the log_bin = ... line in your my.cnf, and restarting the server. mysql will run fine without it.

You can manually view the binary logs within mysql by executing show binary logs, and you can get rid of them with the purge binary logs command, if you want to leave it active and deal with them from time to time.

Upvotes: 2

Related Questions