Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binary log error in mysql

Tags:

mysql

When I am trying to check binary log:

 SHOW BINARY LOGS;

I get this error:

ERROR 1381 (HY000): You are not using binary logging.

How to resolve this? Can anybody help?

like image 339
Ajay Kadyan Avatar asked Jul 12 '12 05:07

Ajay Kadyan


People also ask

What is binary log in MySQL?

The binary log is a set of log files that contain information about data modifications made to a MySQL server instance. The log is enabled by starting the server with the --log-bin option. The binary log was introduced in MySQL 3.23. 14. It contains all statements that update data.

How do I enable binary logging in MySQL?

From MySQL 8.0, binary logging is enabled by default, whether or not you specify the --log-bin option. The exception is if you use mysqld to initialize the data directory manually by invoking it with the --initialize or --initialize-insecure option, when binary logging is disabled by default.

How do I stop binary logs in MySQL?

To disable the MySQL Binary Logging, you can use the --skip-log-bin or --disable-log-bin option at startup.

How do I read MySQL binary logs?

You can use mysqlbinlog to read binary log files directly and apply them to the local MySQL server. You can also read binary logs from a remote server by using the --read-from-remote-server option. To read remote binary logs, the connection parameter options can be given to indicate how to connect to the server.


1 Answers

Set the log-bin variable in your MySQL configuration file, then restart MySQL.

An example my.cnf (on Linux/unix) or my.ini (on Windows) would look like:

[client]
...

[mysqld]
...
log-bin=mysql-bin
---

Once restarted, MySQL automatically creates a new binary log (does so upon every restart). You may also wish to look at the following variables:

server-id        = 1
expire_logs_days = 4
sync_binlog      = 1

Read details on the MySQL documentation. If you're after replication setup (a primary reason for using binary logs), check out Replication configuration checklist.

like image 100
Shlomi Noach Avatar answered Oct 16 '22 01:10

Shlomi Noach