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.

my database files located in /var/lib/mysql which located in partition /dev/sda5

this partition is full (refer here for details)

so I'm going to move the location of database files from /var/lib/mysql to /home/lib/mysql

What is the right way to move this database files?

Im going to do this steps:

  1. Stop http server and PHP
  2. Change datadir=/var/lib/mysql to become datadir=/home/lib/mysql in /etc/my.cnf
  3. move all database files to the new location
  4. run killall -9 mysql, then /etc/init.d/mysqld start
  5. Start http server and PHP

Is this right? Correct me if I'm wrong

added:

currently, mysql won't stop. refer here: mysql wont stop, mysqld_safe appeared in top

share|improve this question
add comment

2 Answers

1- You should stop the mysql server (step 4) before moving the files (step 3).

2- You should stop it gracefully not using kill -9 unless needed to.

3- I think you mean start in step 5. (I edit the question).

4- You need also to check the files permissions and ownership.

share|improve this answer
    
currently, mysql won't stop. refer here: serverfault.com/questions/214922/… –  kopeklan Dec 22 '10 at 15:08
add comment
  1. stop http server and PHP
  2. login as root into mysql and "flush tables" (if flush fails you will have some tables to repair)
  3. run killall -9 mysql
  4. Change datadir=/var/lib/mysql to become datadir=/home/lib/mysql in /etc/my.cnf
  5. move all database files to the new location
  6. start mysql server
  7. check tables status (from phpmyadmin or other gui)
  8. start http server and PHP
share|improve this answer
    
That should be a very last resort for shutting down a mysql server - first step would be to carefully examine everything on sda5 to see if anything can be deleted or removed temporarily. –  symcbean Dec 22 '10 at 17:22
    
why need "flush tables"? –  kopeklan Dec 22 '10 at 17:23
    
Kopeklan wrote: currently, mysql won't stop. Flush tables: for write any cache before kill mysql. –  lg. Dec 23 '10 at 8:54
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.