简体   繁体   English

my.cnf和mysql.cnf有什么区别?

[英]What is the difference between my.cnf vs mysql.cnf?

In /etc/mysql/ I see two config files: my.cnf and mysql.cnf 在/ etc / mysql /中我看到两个配置文件:my.cnf和mysql.cnf

Both have almost identical contents. 两者的内容几乎相同。 One of them has been recently updated via apt-get. 最近通过apt-get更新了其中一个。 Looks like one of them is obsolete. 看起来其中一个已经过时了。

Can somebody explain what's the difference between these two and if I can delete one of them? 有人可以解释这两者之间的区别是什么,如果我可以删除其中一个?

Using Ubuntu 16.10 and Mysql 5.7.8 here. 在这里使用Ubuntu 16.10和Mysql 5.7.8。

tl;dr They are the same file. tl; dr他们是同一个文件。

In Ubuntu 16.04 /etc/mysql/my.cnf is a symlink to /etc/alternatives/my.cnf which by default is a symlink to /etc/mysql/mysql.cnf . 在Ubuntu 16.04 /etc/mysql/my.cnf是一个符号链接/etc/alternatives/my.cnf默认为一个符号链接/etc/mysql/mysql.cnf

Seems like a lot of symlinks, but they wanted MySQL to read from /etc/mysql/my.cnf and also use the alternatives mechanism. 看起来像很多符号链接,但他们希望MySQL从/etc/mysql/my.cnf读取并使用替代机制。

I have the same question. 我也有同样的问题。

I will assume you meant /etc/mysql/my.cnf and /etc/mysql/mysql.cnf because I actually have a lot of MySQL configuration files. 我假设您的意思是/etc/mysql/my.cnf/etc/mysql/mysql.cnf因为我实际上有很多MySQL配置文件。

I tested and both are required - MySQL will not start up unless they are both present, even though they contain the same content. 我测试过,两者都是必需的 - 除非它们都存在,否则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/

From what I understand, mysql.cnf are the Ubuntu specific MySQL settings and my.cnf are the MySQL default settings. 根据我的理解, mysql.cnf是Ubuntu特定的MySQL设置, my.cnf是MySQL的默认设置。

The MySQL documentation contains a table describing what the various config files are supposed to be used for, but it doesn't mention mysql.cnf. MySQL文档包含一个表,描述了各种配置文件应该用于什么,但它没有提到mysql.cnf。

  • /etc/my.cnf Global options /etc/my.cnf全球选项
  • /etc/mysql/my.cnf Global options /etc/mysql/my.cnf全局选项
  • SYSCONFDIR/my.cnf Global options SYSCONFDIR/my.cnf全局选项
  • $MYSQL_HOME/my.cnf Server-specific options (server only) $MYSQL_HOME/my.cnf特定于服务器的选项(仅限服务器)
  • defaults-extra-file The file specified with --defaults-extra-file, if any defaults-extra-file使用--defaults-extra-file指定的文件(如果有)
  • ~/.my.cnf User-specific options ~/.my.cnf用户特定选项
  • ~/.mylogin.cnf User-specific login path options (clients only) ~/.mylogin.cnf用户特定的登录路径选项(仅限客户端)

And as you can see by the contents of these two config file from this blog my theory seems to be correct. 正如你可以从这个博客中看到这两个配置文件的内容我的理论似乎是正确的。

On my system, I actually have quite a few other configuration files which correspond to the various sections of the MySQL, so you can edit those instead of using the various sections. 在我的系统上,我实际上有相当多的其他配置文件对应于MySQL的各个部分,因此您可以编辑它们而不是使用各个部分。

[mysqld] 的[mysqld]

These properties are for the MySQL Server, and you can use this file: /etc/mysql/mysql.conf.d/mysqld.cnf 这些属性适用于MySQL Server,您可以使用此文件: /etc/mysql/mysql.conf.d/mysqld.cnf

[mysql] [MySQL的]

These properties are for the MySQL Client (command line), and you can use this file: /etc/mysql/conf.d/mysql.cnf 这些属性适用于MySQL客户端(命令行),您可以使用此文件: /etc/mysql/conf.d/mysql.cnf

[mysqld_safe] [mysqld_safe的]

These properties are for MySQL when you start it up in safe mode using mysql_safe and can be found in this file: /etc/mysql/conf.d/mysqld_safe_syslog.cnf 当您使用mysql_safe以安全模式启动时,这些属性适用于MySQL,可在此文件中找到: /etc/mysql/conf.d/mysqld_safe_syslog.cnf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM