Skip to main content

Moving SQL to another drive

Comments

10 comments

  • GOT
    Easiest way to do this: Go into service manager in WHM and disable monitoring for mysql service mysql stop mkdir /home/var cp -rav /var/lib/mysql /home/var/ mv /var/lib/mysql /var/lib/mysql.old ln -s /home/var/mysql /var/lib/mysql service mysql start
    Make sure mysql starts and all databases are visible. You can then archive or delete the mysql.old fodler once you are sure everything is working as expected.
    0
  • JWolfe
    Many thanks for your reply and help GOT. Seems simple enough and wanted to double check, just in case. Thought there might be a little more to it, but seems not the case. :)
    0
  • GOT
    There's certainly more than one way to skin a cat as they say, but this is how we normally do it for our clients, unless mysql is moving to a dedicated drive, then its a bit different, but this would work fine in your case.
    0
  • JWolfe
    Decided to take the plunge and try, ended up with errors and maria failed to start. 'Job for mariadb.service failed because the control process exited with error code. See "systemctl status mariadb.service" and "journalctl -xe" for details.' I tried renaming the the access_control file and checked permissions but still all failed, so had to roll back to original settings. Do i need to make any changed to /etc/my.cnf ? Many thanks
    0
  • GOT
    Are you running cloudlinux by chance?
    0
  • JWolfe
    No CentOS 7
    0
  • GOT
    There are special steps if you were running cloudlinux with cagefs and mariadb but I've never seen an issue where this didn't work. You would need to go through the steps again and then check the logs and the journalctl command to see what the error was. Tough to try to diagnose in a forum style environment since no one wants mysql down for an extended period of time. Using this method you would not need to change anything in your my.cnf for it to work right generically speaking.
    0
  • JWolfe
    Thanks for the reply. That's what i thought and wouldn't have to change anything in my.cnf by creating a symbolic link. Your right, didn't want SQl down for too long lol. Will give it another shot tomorrow. Thanks once again.
    0
  • cPanelMichael
    Hello @JWolfe, MariaDB uses the default systemd unit configuration that enables the "ProtectSystem" and "ProtectHome" features. Thus, configuring MariaDB to use a data directory within /home, /usr, /etc, /boot, or /root is unsupported and will prevent MariaDB from starting. You can read more about this on the following thread:
    0
  • JWolfe
    Many thanks for the reply Michael, that would certainly explain my problem and why.
    0

Please sign in to leave a comment.