mysqlubuntumysql-5.6ubuntu-15.04

Unable to enable logs in MySQL - error : Found option without preceding group in config file


I am trying to enable logs on my MySQL server but with no success. What I have done :

1) I have created the log file with the right permissions :

touch /var/log/mysql/mysql.log   
chown mysql:mysql /var/log/mysql/mysql.log

2) I have added the needed change to the my.cnf file :

general_log_file        = /var/log/mysql/mysql.log
general_log             = 1

My my.cnf file is the following :

#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

general_log_file        = /var/log/mysql/mysql.log
general_log             = 1

I am unable to restart MySQL and when I try to logging, I have this error :

error: Found option without preceding group in config file: /etc/mysql/my.cnf at line: 23 Fatal error in defaults handling. Program aborted

What does that mean and how I can fix this ?

I am using Ubuntu 15.05 with MySQL 5.6.24-0ubuntu2


Solution

  • Perhaps you should add [mysqld] as a first line of your my.cnf file.