Migrate MySQL to another partition in same server

Posted on

Question :

I have a instance of MySQL in a local server. To improve the performance, I put a SSD just for MySQL.

Now I need migrate the MySQL instance, with my databse (a data has 25GB) for the SSD.

What the best way to do that?
I thinked in export the data and after reinstall the MySQL in SSD and import the data again. But how is a big database, I will have a large downtime.

Are there a another way?

Answer :

For linux (as root user)

  1. Stop mysql service through systemctl
  2. rsync or cp -a the whole of /var/lib/mysql to your preferred destination.
  3. mv /var/lib/mysql /var/lib/mysql-old
  4. edit mysql configuration file and change datadir= under mysqld
  5. Start mysql service through systemctl.

Leave a Reply

Your email address will not be published. Required fields are marked *