HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

MySQL 5.6 OS X 10.8: how tell if my.cnf read?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
readcnftellmysqlhow

Problem

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.

Solution

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

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)

mysql>

Code Snippets

mysqld --help --verbose | head -20 > junk.txt
cat junk.txt
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
owners.

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 #.
/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf
mysqld --help --verbose | head -20 > junk.txt
cat junk.txt
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)

mysql>

Context

StackExchange Database Administrators Q#36889, answer score: 2

Revisions (0)

No revisions yet.