简体   繁体   中英

What is the difference between my.cnf vs mysql.cnf?

In /etc/mysql/ I see two config files: my.cnf and mysql.cnf

Both have almost identical contents. One of them has been recently updated via 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.

tl;dr They are the same file.

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 .

Seems like a lot of symlinks, but they wanted MySQL to read from /etc/mysql/my.cnf and also use the alternatives mechanism.

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.

I tested and both are required - MySQL will not start up unless they are both present, even though they contain the same content.

# 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.

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.

  • /etc/my.cnf Global options
  • /etc/mysql/my.cnf Global options
  • SYSCONFDIR/my.cnf Global options
  • $MYSQL_HOME/my.cnf Server-specific options (server only)
  • defaults-extra-file The file specified with --defaults-extra-file, if any
  • ~/.my.cnf User-specific options
  • ~/.mylogin.cnf User-specific login path options (clients only)

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.

[mysqld]

These properties are for the MySQL Server, and you can use this file: /etc/mysql/mysql.conf.d/mysqld.cnf

[mysql]

These properties are for the MySQL Client (command line), and you can use this file: /etc/mysql/conf.d/mysql.cnf

[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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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