为什么/etc/mysql/my.cnf EMPTY?
我正在尝试编辑my.cnf
文件以允许远程访问并最终使用我的Windows Server中的软件来配置MySQL服务器的计划备份。
我正在遵循这些指示 。 但是,我的Ubuntu上的/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/
它不包含我可以编辑的任何配置。 为什么会那样?
首先,正如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
该文件不为空。 它包含注释,行带有#
的行和import语句,带有前导的行!
。 import语句意味着,也将使用其他配置。
编辑配置也意味着添加新的配置行。
我的文件是一样的。 您需要在您尝试放入的命令上方添加正确的组,否则服务将无法启动。
要添加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. # [mysqld] bind-address = 0.0.0.0 !includedir /etc/mysql/conf.d/ !includedir /etc/mysql/mysql.conf.d/
注意[mysqld]组。
在这种情况下,该文件不是关于bind-adress,binlogs等所有信息的主要文件。 但是还有另一个文件,包括它们。 试试这个:
nano /etc/mysql/mysql.conf.d/mysqld.cnf
它帮助了我,它应该帮助你。