With mysqld running, I expect to see that /etc/my.cnf has been used by at least one of the commands

ps aux | grep mysql | grep -v grep

mysqladmin variables | grep defaults-file

showing the value of --defaults-file. But I see no such item. Why not?

I think /etc/my.cnf is being read, since if I put an erroneous entry in its [mysqld] section, e.g., error = true then when I try to start mysqld it aborts with an ERROR message.

I'm using the installation by running mysql-5.6.10-osx10.7-x86_64.pkg from mysql-5.6.10-osx10.7-x86_64.dmg.


Whenever mysqld is launched, it has four default locations it attempts to locate and read my.cnf

If you run the following:

mysqld --help --verbose | head -20 > junk.txt
cat junk.txt

You will see this:

mysqld  Ver 5.6.10 for Linux on x86_64 (MySQL Community Server (GPL))
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Starts the MySQL database server.

Usage: mysqld [OPTIONS]

Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf
The following groups are read: mysqld server mysqld-5.6
The following options may be given as the first argument:
--print-defaults        Print the program argument list and exit.
--no-defaults           Don't read default options from any option file,
                        except for login file.
--defaults-file=#       Only read default options from the given file #.

Note the line that says:

/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf

These are the four files read (if they exist).

The above displays come from a Linux Box. So, please run

mysqld --help --verbose | head -20 > junk.txt
cat junk.txt

and see what locations are echoed.

UPDATE 2013-03-17 22:35 EDT

The reason you cannot see the --defaults-file option is not visible is simple: Since one or more of the default my.cnf files are present, mysqld_safe does not show it on the command line.

Please note the following:

  • mysqld uses the four defaults
  • You cannot set --defaults-file for mysqld. That's the job of mysqld_safe
  • mysqld_safe needs it explicitly specified in order for it to be visible in the OS

Running SHOW GLOBAL VARIABLES; will not show any defaults file

mysql> show global variables like '%def%';
| Variable_name          | Value  |
| default_storage_engine | InnoDB |
| default_week_format    | 0      |
| table_definition_cache | 400    |
3 rows in set (0.00 sec)

  • On my Mac I see locations /etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf in that output, the 3 options you show, and one more: --defaults-extra-file=# Read this file after the global files are read. But this still doesn't answer my question: should I be seeing the value of defaults-file when I make the queries I originally showed? – murray Mar 18 '13 at 0:52
  • OK, thanks, that 2013-03-17 update does clarify the situation. Thanks! – murray Mar 18 '13 at 13:42

On OS X, here is a simple method to check whether your file is read.

  1. Run: sudo fs_usage | grep my.cnf

    This will report any filesystem activity in real-time related to that file.

  2. In another Terminal, restart your MySQL/MariaDB server, e.g.

     brew services restart mysql # or: mariadb
  3. On terminal with fs_usage, the proper location should be shown, e.g.

     15:52:22  access            /usr/local/Cellar/mariadb/10.1.14/my.cnf                                         0.000002   sh

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.