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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have one master and one slave replicating great, but the master is about to have both it's hostname and IP changed. In on the slave server I see the current hostname for the master, if I shutdown the slave server, change the hostname in that file and then restart MySQL will that be all I need? No usernames/passwords etc are changing.

If I used CHANGE MASTER queries instead it looks like it will require re-setting the binlog position etc?

share|improve this question
up vote 3 down vote accepted

Once you change the MASTER_HOST, everything else needs to change with it.

The "dark back-alley" approach you just suggested is exactly what to do.

On the Slave, run these four lines:

cd /var/lib/mysql
service mysql stop
wc -l <

The last line echoes the number of lines in

Next, vi and change the IP address.

Next, run wc -l < and make sure the linecount is still the same

Next, start mysql without starting replication

service mysql start --skip-slave-start

Login to MySQL, and run


If the IP address you added appears, then run


If you see Slave_IO_Running : Yes and Slave_SQL_Running : Yes, Congratulations !!!

Give it a Try !!!

share|improve this answer
Hey i was reading this… Why not doing it like this? STOP SLAVE; SHOW SLAVE STATUS; Master_Log_File: mysql-bin.000101 Read_Master_Log_Pos: 591523680 CHANGE MASTER TO MASTER_HOST='NEW IP ADDRESS', MASTER_LOG_FILE='mysql-bin.000101', MASTER_LOG_POS=591523680; START SLAVE; – bicycle Feb 24 '14 at 11:13

Your Answer


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.