簡體   English   中英

my.cnf和mysql.cnf有什么區別?

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

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

根據我的理解, 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM