MySQL Backup and Restore

This is a script to run when using an SSH connection to move a MySQL database to another host.

mysqldump --host=<host_ip_address> --user <db_username> --password=<db_password> <database_name> > mysqldump.sql

mysql -u <db_username> -p <db_password> -h <host_ip_address> <database_name> < mysqldump.sql

In the first line you should replace the bits in brackets with the host database you need to backup and the second line should be the details of the host you are restoring to.

Localhost is the default host so the --host= and -h could dropped if you are working locally.

Add new comment