为什么 /etc/mysql/my.cnf 是空的?

Mer*_*dez 19 server mysql

我正在尝试编辑该my.cnf文件以允许远程访问并最终使用我的 Windows Server 中的软件为 MySQL Server 配置计划备份。

我正在遵循这些说明。但是,/etc/mysql/my.cnf我的 Ubuntu 上的文件只有:

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

它不包含任何我可以编辑的配置。为什么会这样?

小智 33

首先,正如 AB 正确指出的那样,文件不是空的。它有两个相当重要的指令,即

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
Run Code Online (Sandbox Code Playgroud)

这些行表示可以在列出的目录中找到其他配置文件(在本例中为 .cnf):

/etc/mysql/conf.d/
/etc/mysql/mysql.conf.d/
Run Code Online (Sandbox Code Playgroud)

两个目录中的后者应包含mysqld.cnf。换句话说,适当的配置文件应该是:

/etc/mysql/mysql.conf.d/mysqld.cnf
Run Code Online (Sandbox Code Playgroud)

  • 无论如何都不对劲。当我编辑中途清空 my.conf 文件并例如设置 wait_timeout = 600 时,服务 mysql 无法再启动.. (2认同)

A.B*_*.B. 6

该文件不为空。它包含注释——带前导的行#——和导入语句——带前导的行!。导入语句意味着也将使用其他配置。

编辑配置文件也意味着添加新的配置行。


Rob*_*Rob 5

我的文件是一样的。您需要在您尝试放入的命令上方添加正确的组,否则服务将无法启动。

要添加,bind-address您需要添加[mysqld]上方。

如果您需要检查哪些群体是其他命令,有一个例子my.cnf文件在这里

如果您想从所有接口(即 0.0.0.0)启用远程连接,您的文件将如下所示,但是如果您这样做,请确保您正确设置了防火墙。

#
# 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/

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

注意 [mysqld] 组。