Mysql Remote Restore

Backup and Restore MySQL Databases and Tables by Eric on February 1, 2020

Anytime I need to move data or alter our database I get a little bit nervous that something is going to go wrong and crash the database losing all of our data, dropping tables, causing chaos, and so many phone calls.  Our database automatically backs up every so often but right before any major changes I make a quick local copy of the data.  This came in handy just the other day when a table was inadvertently dropped and I had a backup on hand.  Here's how to do it using console commands.Making a Backup of a Databasemysqldump -u [username] -p --host=[hostname] [database_name] > [output_name].sqlRestoring a Database from a Backup Make sure the database is created before restoring.mysql -u [username] -p --host=[hostname] [database_name] < [output_name].sqlMaking a Backup of a Table in a Databasemysqldump -u [username] -p --host=[hostname] [database_name] [table_name] > [table_name].sqlRestoring a Table from a Backup Make sure the table has been created already and MySQL will know wher...