Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. SQL Server
  3. Question
SQL Server

How to disable mysql binary log with log_bin variable?

Asked by Dipika Agarwal Mar 15, 2023 2.8K views 2 answers
Share

About this question

 Default MySQL config file /etc/mysql/my.cnf installed by some debian package using APT often set log_bin variable, so binlog are enabled:

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

When I want to disable binary logging on such installation, comment out the line in my.cnf works of course, but I wonder if there is a way to disable binary logging by setting explicitly log_bin to OFF, in a debian style, I mean in an included file like /etc/mysql/conf.d/myCustomFile.cnf, so default my.cnf is not changed and can be easily updated by apt, if necessary.


I tried "log_bin = 0", "log_bin = OFF" or "log_bin =" but none works…

Your answer

2 Answers

Ranjana Admin JanBask Expert Latest answer

Answered on Jun 3, 2024

To disable the MySQL binary log, you need to modify the MySQL server configuration. The binary log is controlled by the log_bin system variable. Disabling it involves editing the MySQL configuration file (my.cnf or my.ini, depending on your operating system) and ensuring the log_bin variable is not set or is commented out. Here's a step-by-step guide to do this:


Steps to Disable MySQL Binary Log
Locate the MySQL Configuration File:
On Linux/Unix: /etc/mysql/my.cnf or /etc/my.cnf
On Windows: C:ProgramDataMySQLMySQL Server X.Ymy.ini

Edit the Configuration File:

Open the configuration file in a text editor with appropriate permissions (e.g., using sudo on Linux).

  sudo nano /etc/mysql/my.cnf

Modify the log_bin Setting:

Search for the log_bin setting in the configuration file. If it is set, either comment it out or remove it entirely. Commenting out a line is done by adding a # at the beginning of the line.

Modify the log_bin Setting:

Search for the log_bin setting in the configuration file. If it is set, either comment it out or remove it entirely. Commenting out a line is done by adding a # at the beginning of the line.

# Comment out or remove these lines to disable binary logging

# log_bin
# log_bin_basename
# log_bin_index

Ensure there are no active log_bin settings. The section of the configuration file might look like this after modification:

[mysqld]
# Binary logging is disabled
# log_bin = /var/log/mysql/mysql-bin.log

Restart the MySQL Server:

After modifying the configuration file, restart the MySQL server to apply the changes.


Was this helpful?

More SQL Server discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest SQL Server Blogs

Guides, tips and career advice on SQL Server from JanBask experts.