The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

to move /var/lib/mysql

Discussion in 'General Discussion' started by upsforum, Sep 24, 2007.

  1. upsforum

    upsforum Well-Known Member

    Joined:
    Jul 27, 2005
    Messages:
    446
    Likes Received:
    0
    Trophy Points:
    16
    Hi all,

    My partition /var is full, I can to move /var/lib/mysql to /home partition?

    thanks
    Alessio
     
  2. graham_w

    graham_w Well-Known Member

    Joined:
    May 25, 2004
    Messages:
    50
    Likes Received:
    0
    Trophy Points:
    6
    I used this guide to move the MySQL directory successfully recently :

    http://www.eth0.us/mysql-dir

    Only thing I did differently was completely stop MySQL
    before I copied.

    Good luck!
     
  3. jayh38

    jayh38 Well-Known Member

    Joined:
    Mar 3, 2006
    Messages:
    1,215
    Likes Received:
    0
    Trophy Points:
    36
  4. upsforum

    upsforum Well-Known Member

    Joined:
    Jul 27, 2005
    Messages:
    446
    Likes Received:
    0
    Trophy Points:
    16
    this is correct?


    --------------

    # stop services
    /etc/rc.d/init.d/chkservd stop
    /etc/rc.d/init.d/mysql stop


    # double check mysql has stopped
    ps aux|grep mysql

    # copy databases to a new location
    cp -r /var/lib/mysql /newpath/mysql


    alter /etc/my.cnf

    change
    datadir=/var/lib/mysql
    to
    datadir=/newpath/mysql


    # restart services
    /etc/rc.d/init.d/mysql start
    /etc/rc.d/init.d/chkservd start
     
  5. linux.newbie

    linux.newbie Well-Known Member

    Joined:
    Sep 8, 2006
    Messages:
    73
    Likes Received:
    0
    Trophy Points:
    6
    Do you really have to change the data directory ?
    Why not create a sym link from /var/lib/ to the new path ?
     
  6. upsforum

    upsforum Well-Known Member

    Joined:
    Jul 27, 2005
    Messages:
    446
    Likes Received:
    0
    Trophy Points:
    16
    Thiss explane the correct procedure:

    # stop services
    /etc/rc.d/init.d/chkservd stop
    /etc/rc.d/init.d/mysql stop


    # double check mysql has stopped
    ps aux|grep mysql

    # copy databases to a new location
    ls -s /var/lib/mysql /backup/mysql


    alter /etc/my.cnf

    change
    datadir=/var/lib/mysql
    to
    datadir=/newpath/mysql


    # restart services
    /etc/rc.d/init.d/mysql start
    /etc/rc.d/init.d/chkservd start

    thank you very much
    Alessio
     
  7. bin_asc

    bin_asc Well-Known Member

    Joined:
    Jul 18, 2005
    Messages:
    280
    Likes Received:
    0
    Trophy Points:
    16
    # stop services
    /etc/rc.d/init.d/chkservd stop
    /etc/rc.d/init.d/mysql stop
    or service mysqld stop


    # double check mysql has stopped
    ps aux | grep mysql

    # copy databases to a new location
    ln -s /var/lib/mysql /backup/mysql

    Don`t change the datadir, as that is why you created the symlink for.

    # restart services
    /etc/rc.d/init.d/mysql start
    /etc/rc.d/init.d/chkservd start
    or service mysqld start
     
  8. jayh38

    jayh38 Well-Known Member

    Joined:
    Mar 3, 2006
    Messages:
    1,215
    Likes Received:
    0
    Trophy Points:
    36
    The datadir would need to be changed in order for cpbackup to include the new location.
     
  9. bin_asc

    bin_asc Well-Known Member

    Joined:
    Jul 18, 2005
    Messages:
    280
    Likes Received:
    0
    Trophy Points:
    16
    Depends if he does backups. It would still backup even with the symlink. Even with a restore and the symlink created, it would restore to the good paths. Either way, I would leave it untouched.
     
Loading...

Share This Page