如何修复:mysql:[ERROR]在配置文件/etc/mysql/my.cnf中找到没有前面组的选项?

Rya*_*yan 7 mysql

我在尝试访问mysql时收到以下错误:

mysql:[ERROR]在第22行的配置文件/etc/mysql/my.cnf中找到没有前面组的选项!mysql:[ERROR]默认处理中的致命错误.程序中止了!

/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
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激.

Bil*_*win 11

my.cnf中的所有选项都需要在"组"中,例如:

[mysqld]
bind-address 127.0.0.1
Run Code Online (Sandbox Code Playgroud)

此示例中的组是"mysqld".该组由选项前面的一行命名,该组的名称在方括号中.

在开始提供选项之前,您的文件没有任何组标识符.

有关如何格式化MySQL选项文件的更多详细信息,请阅读https://dev.mysql.com/doc/refman/5.7/en/option-files.html.