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.

Move Mysql my.cnf

Discussion in 'General Discussion' started by kernow, May 15, 2014.

  1. kernow

    kernow Well-Known Member

    Joined:
    Jul 23, 2004
    Messages:
    865
    Likes Received:
    9
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Hi,
    After moving mysql to new location and adding symlink, is it required to edit my.cnf and add:
    mysql.sock=new-location
    datadir=new-location
    ?
    And why when new database is created does it get created ( symlink i guess) in /var/lib/mysql as well as new location?
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    It depends on how you moved the MySQL directory. If you added a symbolic link, then technically it's not required to modify the "datadir" or "mysql.sock" entries in the /etc/my.cnf file. Additional symbolic links are not required if you already created one for the /var/lib/mysql location.

    Thank you.
     
  3. kernow

    kernow Well-Known Member

    Joined:
    Jul 23, 2004
    Messages:
    865
    Likes Received:
    9
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Hi, thanks for your help.
    The way we moved mysql was basically;
    Code:
    etc/init.d/mysql stop
    ]mkdir /data/mysql
    mv /var/lib/mysql /data/mysql
    chown -R mysql:mysql /data/mysql
    ln -s /data/mysql/mysql /var/lib/mysql
    /etc/init.d/mysql start
    So why when a new database is created does a link get created in /var/lib/mysql to /data/mysql / ? Can we not edit my.cnf so any call to a database goes to the new location directly rather than to /var/lib/mysql > read link to new database location > database
    ?
    Regards.
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  5. kernow

    kernow Well-Known Member

    Joined:
    Jul 23, 2004
    Messages:
    865
    Likes Received:
    9
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Hi,
    No trouble, am looking for efficiency and speed. Just wanting a call for any database to go straight to the new location instead of via /var/lib/mysql link to user_database in new location.
    Also wanting any new database to be created in the new location only, without adding a link to it in /var/lib/mysql . As it is, if I were to delete a link in /var/lib/mysql the database in its new location would vanish.
     
    #5 kernow, May 16, 2014
    Last edited: May 16, 2014
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    You could add or edit the following entry in the /etc/my.cnf file:

    Code:
    datadir=/path/to/new/mysql
    However, to clarify, are you actually running out of space in the /var partition?

    Thank you.
     
  7. kernow

    kernow Well-Known Member

    Joined:
    Jul 23, 2004
    Messages:
    865
    Likes Received:
    9
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Hi,
    Adding datadir=/path/to/new/mysql does not make any difference. Create a new database and it gets created in new location /data/mysql but a link to it also gets created in /var/lib/mysql
    No disk space is not a problem, we added a SSD drive and moved mysql onto it to increase access speed.
     
  8. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Feel free to open a support ticket if you would like us to take a closer look. I'm not sure exactly how your existing configuration looks so it's difficult to give an accurate answer. Note that symbolic links should not actually result in reduced performance.

    Thank you.
     
Loading...

Share This Page