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!

Move database to second disk

Discussion in 'General Discussion' started by ASTRAPI, Feb 9, 2010.

  1. ASTRAPI

    ASTRAPI Well-Known Member

    Joined:
    Jul 8, 2008
    Messages:
    321
    Likes Received:
    0
    Trophy Points:
    66
    Hello

    I want to move my database to my second disk and i was read that i must found the folder for mysql that contains all that info and to copy it in the second disk and then set from my.cnf the path to lod it from the second disk.

    How can i locate this folder?

    Is there something else to do for that to work?

    Thank you
     
  2. cPanelDon

    cPanelDon cPanel Quality Assurance Analyst
    Staff Member

    Joined:
    Nov 5, 2008
    Messages:
    2,544
    Likes Received:
    9
    Trophy Points:
    268
    Location:
    Houston, Texas, U.S.A.
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    MySQL databases are typically stored within the following directory path:
    Code:
    /var/lib/mysql/
    When moving the MySQL data directory, as seen above, it is usually required to update the MySQL configuration file (at "/etc/my.cnf") and as a precaution one may want to create a symbolic link (symlink) from the original path to the new path.

    When performing any changes the MySQL server should be fully shutdown and not actively running to minimize the potential for data loss. Due to the risk involved extreme caution is advised.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. ASTRAPI

    ASTRAPI Well-Known Member

    Joined:
    Jul 8, 2008
    Messages:
    321
    Likes Received:
    0
    Trophy Points:
    66
    How can i create this?


    Thank you
     
  4. boatdesign

    boatdesign Well-Known Member

    Joined:
    Sep 13, 2003
    Messages:
    158
    Likes Received:
    0
    Trophy Points:
    166
    ln -s /path/to/mysqlnewdirectory mysqlolddirectory
     
  5. cPanelDon

    cPanelDon cPanel Quality Assurance Analyst
    Staff Member

    Joined:
    Nov 5, 2008
    Messages:
    2,544
    Likes Received:
    9
    Trophy Points:
    268
    Location:
    Houston, Texas, U.S.A.
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    The example posted by boatdesign is valid. Here is another example just for clarification; as a precaution I've added an additional option "-n" and enabled verbose output:
    Code:
    # ln -nsv /new/path/to/mysql /old/path/to/mysql
    For usage information I recommend referring to the manual "man" page and help documentation for "ln":
    Code:
    # man ln
    # ln --help
    If the MySQL data directory was moved to a directory path at "/new/mysql/" and if the old location is the same as the stock-default (at "/var/lib/mysql/"), the command to create a symlink could look like the following:
    Code:
    # ln -nsv /new/mysql /var/lib/mysql
    Warning: Any changes to the MySQL data directory should be performed only while MySQL is shutdown.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. ASTRAPI

    ASTRAPI Well-Known Member

    Joined:
    Jul 8, 2008
    Messages:
    321
    Likes Received:
    0
    Trophy Points:
    66
    Is it better to copy the directory and all contents of it or just a few files?

    Thank you
     
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