Thursday, May 8, 2014

Restore a Single Table from a Full MySQL database dump

You need to restore a single table, but you only have a full db dump from MySQL, and you can’t dump a fresh copy of the table.


Here’s an example one-liner that restores a single given table from a given full db dump to a given server instance. You can change the “zcat” to just “cat” if you didn’t use gzip to compress it.


zcat path_to_full_GameDB_Slave_Instance_Backup_you_want_to_push_to_PTS | sed -n -e ‘/Table structure for.*`name_of_table_you_want_to_restore/,/Table structure for/p’ | mysql -h ip_of_server_you_want_to_restore_to -P port_of_server_instance_you_want_to_restore_to –protocol=tcp -u mysql_username_on_server_you_want_to_restore_to -p –database=name_of_database_you_want_to_restore_to


Reference:


http://ift.tt/1l2E9ly





No comments:

Post a Comment