MySQL where's the my.cnf path?
Solution 1:
As per this article:
Running this command from the command line / terminal will show where MySQL will look for the my.cnf file on Linux/BSD/OS X systems:
mysql --help | grep "Default options" -A 1
This will output something like this:
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
You can now check for files using the above output at /etc/my.cnf
, then /etc/mysql/my.cnf
and so on. If there isn't one at one of those locations, you can create one and know MySQL will use it.
Solution 2:
On a Linux system 'locate my.cnf" will be the fastest solution.
If there are several my.cnf files, all looking likely (e.g. in /etc
, /etc/mysql
, /opt/mysql/etc
, etc.), then you can run strace
to see where MySQL binary tries to find its configuration file, but I do think that's an overkill.
Solution 3:
OK a wild shot in the dark:
If the database is installed in /usr/local/mysql
, then try looking in /etc/local
for my.cnf
Here is how you can tell if you have a my.cnf
Run this query (<= 5.6.7)
SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME IN ('wait_timeout',
'innodb_buffer_pool_size','innodb_log_file_size');
OR (>= 5.6.8)
it moved to the performance schema.
SELECT * FROM PERFORMANCE_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME IN ('wait_timeout',
'innodb_buffer_pool_size','innodb_log_file_size');
SHOW GLOBAL VARIABLES LIKE 'wait_timeout';
SHOW GLOBAL VARIABLES LIKE 'innodb_buffer_pool_size';
SHOW GLOBAL VARIABLES LIKE 'innodb_log_file_size';
If you should get:
- wait_timeout 28800
- innodb_log_file_size
- Default Value
(>= 5.6.8)
50331648 - Default Value
(<= 5.6.7)
5242880
- Default Value
- innodb_buffer_pool_size 134217728
You are running with defaults and there is a possibility that there may not be a my.cnf
present.
NOTE:
As of MySQL 5.7.6, information available from the tables described here is also available from the Performance Schema. The INFORMATION_SCHEMA tables are deprecated in preference to the Performance Schema tables and will be removed in a future MySQL release. For advice on migrating away from the INFORMATION_SCHEMA tables to the Performance Schema tables, see Section 25.20, “Migrating to Performance Schema System and Status Variable Tables”.