Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

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:
    464
    Likes Received:
    0
    Trophy Points:
    166
    Hi all,

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

    thanks
    Alessio
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. graham_w

    graham_w Well-Known Member

    Joined:
    May 25, 2004
    Messages:
    53
    Likes Received:
    0
    Trophy Points:
    156
    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:
    166
  4. upsforum

    upsforum Well-Known Member

    Joined:
    Jul 27, 2005
    Messages:
    464
    Likes Received:
    0
    Trophy Points:
    166
    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
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. linux.newbie

    linux.newbie Well-Known Member

    Joined:
    Sep 8, 2006
    Messages:
    73
    Likes Received:
    0
    Trophy Points:
    156
    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:
    464
    Likes Received:
    0
    Trophy Points:
    166
    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
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. bin_asc

    bin_asc Well-Known Member

    Joined:
    Jul 18, 2005
    Messages:
    280
    Likes Received:
    0
    Trophy Points:
    166
    # 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:
    166
    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:
    166
    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

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice