O'Reilly logo

MySQL 8 Cookbook by Karthik Appigatla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

  1. Stop the MySQL server:
 shell> sudo systemctl stop mysql
  1. Move the files to the data directory:
 shell> sudo mv /backup/mysql /var/lib
  1. Change the ownership to mysql:
 shell> sudo chown -R mysql:mysql /var/lib/mysql
  1. Start MySQL:
 shell> sudo systemctl start mysql

To minimize the downtime, if you have enough space on disk, you can copy to the backup to /var/lib/mysql2. Then stop MySQL, rename the directory, and start the server:

shell> sudo mv /backup/mysql /var/lib/mysql2shell> sudo systemctl stop mysqlshell> sudo mv /var/lib/mysql2 /var/lib/mysqlshell> sudo chown -R mysql:mysql /var/lib/mysqlshell> sudo systemctl start mysql

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required