Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

mysql

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.

like image 575
Michael Heuberger Avatar asked Mar 28 '17 21:03

Michael Heuberger


1 Answers

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

like image 81
Dagmar Avatar answered Oct 12 '22 11:10

Dagmar