在/ etc/mysql /中我看到两个配置文件:my.cnf和mysql.cnf
两者的内容几乎相同.最近通过apt-get更新了其中一个.看起来其中一个已经过时了.
有人可以解释这两者之间的区别是什么,如果我可以删除其中一个?
在这里使用Ubuntu 16.10和Mysql 5.7.8.
tl; dr他们是同一个文件.
在Ubuntu 16.04中/etc/mysql/my.cnf是一个符号链接/etc/alternatives/my.cnf,默认情况下是符号链接/etc/mysql/mysql.cnf.
看起来像许多符号链接,但他们希望MySQL读取/etc/mysql/my.cnf并使用替代机制.
我也有同样的问题.
我会假设你的意思/etc/mysql/my.cnf,/etc/mysql/mysql.cnf因为我实际上有很多MySQL配置文件.
我测试过,两者都是必需的 - 除非它们都存在,否则MySQL不会启动,即使它们包含相同的内容.
# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
Run Code Online (Sandbox Code Playgroud)
据我所知,mysql.cnf是Ubuntu特定的MySQL设置,my.cnf是MySQL的默认设置.
在MySQL文档包含了描述各种配置文件应该使用哪些对一个表,但它没有提到mysql.cnf.
/etc/my.cnf 全球选择/etc/mysql/my.cnf 全球选择 SYSCONFDIR/my.cnf 全球选择$MYSQL_HOME/my.cnf 特定于服务器的选项(仅限服务器)defaults-extra-file 使用--defaults-extra-file指定的文件(如果有) ~/.my.cnf 用户特定选项~/.mylogin.cnf 用户特定的登录路径选项(仅限客户端)正如你可以从这个博客中看到这两个配置文件的内容我的理论似乎是正确的.
在我的系统上,我实际上有相当多的其他配置文件对应于MySQL的各个部分,因此您可以编辑它们而不是使用各个部分.
的[mysqld]
这些属性适用于MySQL Server,您可以使用此文件: /etc/mysql/mysql.conf.d/mysqld.cnf
[MySQL的]
这些属性适用于MySQL客户端(命令行),您可以使用此文件: /etc/mysql/conf.d/mysql.cnf
[mysqld_safe的]
当您使用mysql_safe以安全模式启动它时,这些属性适用于MySQL ,可以在此文件中找到:/etc/mysql/conf.d/mysqld_safe_syslog.cnf