Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix: mysql: [ERROR] Found option without preceding group in config file /etc/mysql/my.cnf?

Tags:

mysql

I am getting the following error when trying to access mysql:

mysql: [ERROR] Found option without preceding group in config file /etc/mysql/my.cnf at line 22! mysql: [ERROR] Fatal error in defaults handling. Program aborted!

/etc/mysql/my.cnf

#
# 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/
bind-address = 127.0.0.1
general_log_file = /var/log/mysql/mysql.log
general_log = 1

Any help would be appreciated.

like image 565
Ryan Avatar asked Jun 01 '17 03:06

Ryan


People also ask

Where is my CNF file in MySQL?

cnf is located in /etc/mysql/my. cnf .


2 Answers

All options in your my.cnf need to be within a "group" like:

[mysqld]
bind-address 127.0.0.1

The group in this example is "mysqld". The group is named by a line preceding the options, and the name of the group is in square brackets.

Your file doesn't have any group identifier named before you start giving options.

Read https://dev.mysql.com/doc/refman/5.7/en/option-files.html for more details on how to format MySQL option files.

like image 124
Bill Karwin Avatar answered Sep 16 '22 19:09

Bill Karwin


In my case the group is [mysql]

So just put [mysql] at the beginning.

like image 34
joydeba Avatar answered Sep 20 '22 19:09

joydeba