Skip to content

Instantly share code, notes, and snippets.

@shoaibi
Created January 20, 2017 11:44
Show Gist options
  • Select an option

  • Save shoaibi/e9ece345667f3d39b797f585dfb66618 to your computer and use it in GitHub Desktop.

Select an option

Save shoaibi/e9ece345667f3d39b797f585dfb66618 to your computer and use it in GitHub Desktop.
Restore large databases
echo "Restoring $1"
queries="
-- Set network buffer length to a large byte number\n
set global net_buffer_length=1000000;\n
-- Set maximum allowed packet size to a large byte number\n
set global max_allowed_packet=1000000000;\n
-- Disable foreign key cheking to avoid delays,errors and unwanted behaviour\n
SET foreign_key_checks = 0;\n
source $2;\n
SET foreign_key_checks = 1;\n
"
mysql $1 -e "$queries" > /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment