我正在尝试编辑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/
它不包含任何我可以编辑的配置。为什么会这样?
答案1
首先,正如 AB 正确指出的那样,该文件不为空。它有两个相当重要的指令,即
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
这些台词的意思是额外的配置文件(在本例中为 .cnf)可以在列出的目录中找到:
/etc/mysql/conf.d/
/etc/mysql/mysql.conf.d/
后者应该包含mysqld.cnf换句话说,适当的配置文件应该是:
/etc/mysql/mysql.conf.d/mysqld.cnf
答案2
该文件不为空。它包含注释(以 开头的行#
)和导入语句(以 开头的行)!
。导入语句意味着也将使用其他配置。
编辑配置文件也意味着添加新的配置行。
答案3
我的文件也是一样。您需要在尝试输入的命令上方添加正确的组,否则服务将无法启动。
若要添加,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
注意 [mysqld] 组。
答案4
在 Ubuntu 16.04 / MySQL 5.7 上至少实际上my.cnf
是空的,因为它是指向另一个文件的符号链接,该文件又链接回其他答案mysql.cnf
中/etc/mysql/mysql.conf.d
提到的文件。如上所述在此处进行更改。