Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 an mysql server and I want to change the datadir from /var/lib/mysql to dif_dir/mysql. Is it a simple scp? If not, what are the steps that I need to take?

share|improve this question
  1. Shut down mysql.
  2. Copy data, probably via: $ rsync -avp /path/to/old/loc/ /path/to/new/loc/
  3. Change my.cnf to reflect new location.
  4. Ensure ownership and permissions on new location are correct and that, if applicable, SELinux and/or apparmor profiles are updated to allow mysql to access the new location.
  5. Start up mysql.
  6. If all looks good, delete the db files from the old location.
share|improve this answer
sweet, thank you. – Cubatown Nov 8 '12 at 20:20
@Cubatown - you're welcome. Take note of step #4. That one bit me recently. – EEAA Nov 8 '12 at 21:26

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.