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 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
add comment

1 Answer

  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
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.