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...

Log in to the server where the backups are available:

shell> cat /backups/full_backup.sql | mysql -u <user> -porshell> mysql -u <user> -p < /backups/full_backup.sql

To restore on the remote server, you can mention the -h <hostname> option:

shell> cat /backups/full_backup.sql | mysql -u <user> -p -h <remote_hostname>

When you are restoring a backup, the backup statements will be logged to the binary log, which can slow down the restoration process. If you do not want the restoration process to write to the binary log, you can disable it at the session level using the SET SQL_LOG_BIN=0; option:

shell> (echo "SET SQL_LOG_BIN=0;";cat /backups/full_backup.sql) | mysql -u <user> -p -h <remote_hostname>

Or using:

mysql> SET SQL_LOG_BIN=0; ...

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