Mysql – Unable to start thesqld service after enabling log_bin

binlogMySQLmysqlbinlogmysqldreplication

Hi I am unable to start mysqld service after I make changes in my.cnf to enable log-bin.
After making changes the file looks like below:

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

#This is what I added to enable log-bin

log-bin=/var/log/mysql/
log-bin-index=bin-log.index
max_binlog_size=100M
binlog_format=row
socket=mysql.sock

#That was what I added to enable log-bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

I am using:

[ec2-user@pip my.cnf.d]$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.3 (Maipo)

Following is the ownership and permissions:

d]$ ls -ld /var/log/mysql
drwxrwxrwx. 2 mysql mysql 23 Sep  8 09:01 /var/log/mysql

Following is the error that I get:

[ec2-user@i.d]$ sudo service mysqld start
Redirecting to /bin/systemctl start  mysqld.service
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.

MySQL version is:

Server version: 5.7.19 MySQL Community Server (GPL)

Please let me know if any other detail is required

Best Answer

According to the manual entry for the mysqld option log-bin:

If you specify this option without also specifying a --server-id, the server is not allowed to start.

So it seems you need something like:

[mysqld]
server-id=1
log-bin