【问题标题】:How to fix: mysql: [ERROR] Found option without preceding group in config file /etc/mysql/my.cnf?如何修复:mysql:[错误] 在配置文件 /etc/mysql/my.cnf 中找到没有前面组的选项?
【发布时间】:2017-06-01 03:35:31
【问题描述】:

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

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

/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

任何帮助将不胜感激。

【问题讨论】:

  • 第 22 行是您的绑定地址。问题——因为我也有——他们在说什么前一组?
  • 当我错误地替换了 #The MySQL 数据库服务器配置文件时,我遇到了同样的问题。与前面不带 # 的一些字符对齐。

标签: mysql


【解决方案1】:

你的 my.cnf 中的所有选项都需要在一个“组”中,例如:

[mysqld]
bind-address 127.0.0.1

本例中的组是“mysqld”。组由选项前面的一行命名,组的名称在方括号中。

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

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

【讨论】:

    【解决方案2】:

    在我的情况下,该组是 [mysql]

    所以只需将[mysql] 放在开头即可。

    【讨论】:

    • 如何识别组?
    • 我手动检查了。我认为这是特定于版本的。
    【解决方案3】:

    我删除了文件开头的所有注释(以 # 开头的行)。有效。我只是将 cmets 移到文件末尾以作记录。

    我认为与 MySQL 的预期相比,在 Windows 中保存文件存在 LF - CR/LF 差异。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-29
      • 1970-01-01
      • 1970-01-01
      • 2011-01-29
      • 2013-03-07
      • 2014-02-06
      • 1970-01-01
      • 2017-09-09
      相关资源
      最近更新 更多