0

I'm trying to set bin-log on Google's LAMP stack. Everything is working fine except the log-bin config. Whenever I add log-bin = /var/log/mysql/mysql-bin to /etc/mysql/mysql.conf.d/mysqld.cnf file and restart mysql it throws an error

    # sudo /etc/init.d/mysql restart
[....] Restarting mysql (via systemctl): mysql.serviceJob for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
 failed!

Content of /etc/mysql/mysql.conf.d/mysqld.cnf

[mysqld]
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
datadir         = /var/lib/mysql
log-error       = /var/log/mysql/error.log
bind-address    = localhost
log-bin         = /var/log/mysql/mysql-bin
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

mysql:root might have required permission as mysql can log error on /var/log/mysql/error.log. But anyway I tried these too

chown -R mysql:mysql /var/log/mysql/
chmod 770 /var/log/mysql/
# and
chown -R mysql:root /var/log/mysql/

I already tried the solutions given in these posts but nothing worked for me

https://serverfault.com/questions/502713/mysql-wont-start-if-i-set-the-log-bin

try to change bin log directory: mysql-bin.index not found (Errcode: 13)

https://dba.stackexchange.com/questions/12346/mysql-bin-log-index-not-found

https://dba.stackexchange.com/questions/97816/cant-enable-binary-logging-index-not-found

https://serverfault.com/questions/382945/why-cant-i-get-the-binlog-in-mysql/383580

Binary log error in mysql

mysql error.log content

2018-05-31T20:40:15.934303Z 0 [Note] InnoDB: Starting shutdown...
2018-05-31T20:40:16.034693Z 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
2018-05-31T20:40:16.034934Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 180531 20:40:16
2018-05-31T20:40:17.487431Z 0 [Note] InnoDB: Shutdown completed; log sequence number 3080730
2018-05-31T20:40:17.489847Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2018-05-31T20:40:17.489886Z 0 [Note] Shutting down plugin 'MEMORY'
2018-05-31T20:40:17.489893Z 0 [Note] Shutting down plugin 'CSV'
2018-05-31T20:40:17.489898Z 0 [Note] Shutting down plugin 'sha256_password'
2018-05-31T20:40:17.489901Z 0 [Note] Shutting down plugin 'mysql_native_password'
2018-05-31T20:40:17.490163Z 0 [Note] Shutting down plugin 'binlog'
2018-05-31T20:40:17.490592Z 0 [Note] /usr/sbin/mysqld: Shutdown complete

Detailed error log error-log

lkdhruw
  • 572
  • 1
  • 7
  • 22

1 Answers1

0

This might easily be a problem with the security setup on the server that you run on (AppArmor or SELinux). NOTE that the binary log is not actually a "log" in the same sense as the regular text files that are normally placed in /var/log and you probably don't want to place that file in /var/log, anyway. It could be that in the setup where you run, AppArmor or SELinux rules prevent mysql from writing arbitrary files into /var/log (these rules are over and above what the regular file permissions do and no chmod/chown can avoid them). You may want to look into choosing another directory to save the bin-log into.

Perhaps the database root directory is a better choice (/var/lib/mysql, or whatever mysql is configured to use as the place to store its database files in).

Leo K
  • 5,189
  • 3
  • 12
  • 27