Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Does anyone know if there is a way to confirm if any my.cnf file is being read by MySQL?

I only have the one my.cnf on the machine (and there are no my.ini files) which I have in /etc/my.cnf.

When I run ./mysqld --help --versbose, it doesn't give me the variable I have set in the file, so my assumption was it wasn't loading it or that it was loading a different file.

I tested this by setting my.cnf to 777 and running the command again, this time I get a warning saying the file won't be loaded because it is world writeable.

Is this enough to imply the my.cnf has been loaded and perhaps there is an error in it, causing the variables not to be set or is there some other way of knowing for sure what (if any) my.cnf file is loaded?

share|improve this question
1  
Why are you wondering if it is reading your my.cnf file. If you put a error on the my.cnf file on purpose it should show and error when you restart mysql –  Derek Organ Jan 19 '11 at 14:44
    
So it does, I was able to use that to track down my problem, cheers! –  Toby Jan 19 '11 at 14:59
add comment

3 Answers

up vote 4 down vote accepted

If there's only one my.cnf file, and it's /etc/my.cnf, then that's the one it loads. From the manual:

On Unix, Linux and Mac OS X, MySQL programs read startup options from the following files, in the specified order (top items are used first).

/etc/my.cnf Global options

SYSCONFDIR/my.cnf Global options

$MYSQL_HOME/my.cnf Server-specific options

defaults-extra-file The file specified with --defaults-extra-file=path, if any

~/.my.cnf User-specific options (in your home directory)

So, if you check the other directories and there are no my.cnf files, you can be certain it's loading from /etc/my.cnf.

If you use MYSQLAdministrator, supposedly you can get it from Service Control->Configuration File->Config filename, as per this post.

share|improve this answer
    
You are right, thank you. –  Toby Jan 19 '11 at 14:59
    
locate my.cnf –  Steve Robbins Jan 8 at 23:29
add comment

This is a bit crude but I just got for the process line

ps aux | grep mysql

in the output, the mysql process line will come up and should include the --defaults-file being loaded

share|improve this answer
add comment

Connect to your server and run the query SHOW VARIABLES to verify that the settings you put in your my.cnf file are the ones the server is operating with.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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