Fixing Mysql error “you haven’t provided the mandatory server-id”

The following error was thrown while i was enabling mysql binary logs

Mysql Binary Log

The “binary log”  file contains the  “events” that describe database changes such as table creation operations or changes to table data. This is not used for any read statements like “show” or “select”.

To enable the binary log, start the server with the following option

--log-bin=base_name 

This logging is used mainly for

Replication

In replication, the binary log on the master server provides the records of changes to be sent to slave nodes . These records will then get executes on slaves .

Mysql Recovery

If you are taking mysql full backups hourly, during a recovery, once the backup has been restored, the events in the binary log that were recorded after the backup was made are re-executed to ensure zero data loss.

Binary logging makes the mysql performance slightly slower. But, the benefits of the “binary log” in enabling you to set up master-slave replication and for mysql recovery operations generally outweigh this small performance decrement. I would recommend to run the mysql with “bin-log” enabled even if you don’t use it for replication.

How to fix the error “you haven’t provided the mandatory server-id” ?

To enable mysql binary logging, we need to set the mysql option “server-id” in the configuration.

If it is a master server, set “server-id=1” .  On slaves set any other number. But make sure that  same number is not set on any of other slaves. Restart the mysql once changes are made in the configuration file. You wont see this error once server-id is set properly.

Leave a Reply

Your email address will not be published. Required fields are marked *