今天碰到一个特别郁闷的问题,启动mysql数据库时报错:[ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!经过查询资料,说的都是:

原因:my.ini文件格式是utf-8

解决办法,my.ini文件保存为ANSI格式文件

[ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!_3c

但是我的改了也没有用处,后来才发现,不知道什么时候,我删除了一个#:

  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

#

# 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

bind-address=192.168.1.229

log_bin=mysql-bin

log_slave_updates=1

gtid-mode=ON      #开启GTID

enforce-gtid-consistency

"/etc/my.cnf" 35L, 1143C

错误详情如下:

[root@service1 ~]# service mysqld start

my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!

my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!

my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!

my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!

my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!

my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!

my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!

my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!

my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!

my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!

my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!

my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!

Logging to '/var/lib/mysql/service1.err'.

MySQL Daemon failed to start.

正在启动 mysqld:                                          [失败]