Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have to configure a Mysql server to act as a replication-master.

I modified my.cnf to activate binary logs, but now in order to reload configuration I have to reload the service with /etc/init.d/mysqld restart. The problem is that the server receives several queries per second and I don't want to lose all data that could arrive meanwhile.

Is there a way to reload configuration file my.cnf without restarting the service?

Thank you.

share|improve this question
    
/etc/init.d/restart would restart the whole host. You're probably thinking of /etc/init.d/mysqld restart –  Kevin M Oct 28 '09 at 16:30
    
Yes, I ment mysqld restart. Edited. Thx! –  David Espart Oct 30 '09 at 10:15
add comment

2 Answers

up vote 13 down vote accepted

MySQL Specificly:
The options in my.cnf are system variables. These variables are either dynamic (can be changed at runtime) or not dynamic. The ones that are dynamic, can be changed at run time with the SET variable syntax. You can see the variables with SHOW VARIABLES;. But according to this link in the manual, the binary log option is not dynamic. So it looks like you have to restart. You might want to wait for someone who knows mysql a little better than myself to confirm this however.

Daemons in General:
In Linux, /etc/init.d/ holds scripts that start and stop daemons (services). Since these are scripts, you can view them with a text editor. Many of these scripts will take a reload argument. Looking at my mysql script, reload as an argument uses the mysqladmin command. So the manual for mysqladmin under reload says:

reload

Reload the grant tables.

So looks like in general, this isn't for configuration changes, but rather changes in privileges (Maybe the equivalent flush privileges command? ).

share|improve this answer
    
Hey, very good explanation. It seems that there is no way of doing it without restart though. If nobody answers a solution or a workaround I will accept your question. Thank you. –  David Espart Oct 28 '09 at 13:14
    
According to your link, it looks like SET GLOBAL binlog_format = 'STATEMENT'; would do the trick? –  Kyle Smith Oct 28 '09 at 14:10
    
Other Kyle: Looks like it, but I think binary logging would already have to be enabled for that to do anything (and maybe be set). That variable was introduced later than my current 5.0.x version of mysql so I can't test. –  Kyle Brandt Oct 28 '09 at 15:40
    
I had to search for the SET command syntax - here's a link in case anyone else needs it: dev.mysql.com/doc/refman/5.1/en/set-option.html –  C4H5As Mar 1 '11 at 6:52
    
It's also worth mentioning which variables are dynamic changes as you chance MySQL versions. For instance in 5.x you can enable the slow query log on-the-fly, but in 4.x you can't (as I discovered yesterday!). –  Coops Mar 3 '11 at 9:30
add comment

i've been looking around for a solution for this but wasn't satisfied by the limited help i found. One chap offered a kill -HUP .. didn't work for me ..

what i did was to pause the apache instances .. and then continue them later .. worked like a charm on a server where i have an average of 25 active requests per second.

with sudo (obviously) pkill -STOP httpd && /etc/init.d/mysqld restart && pkill -CONT httpd

ofcourse your apache process name and/or mysql restart scripts may vary from mine, but you get the idea right!

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.