Skip to content

Instantly share code, notes, and snippets.

@qutek
Created February 21, 2019 22:01
Show Gist options
  • Save qutek/6bf51131943a921b5ebd454d806c2fc1 to your computer and use it in GitHub Desktop.
Save qutek/6bf51131943a921b5ebd454d806c2fc1 to your computer and use it in GitHub Desktop.
[Move MySQL Data] Move mysql data to another machine

Move mysql to another machine

Old Server

  • Stop mysql server
  • Copy contents of datadir to another location on disk (~/mysqldata/*)
  • Start mysql server again (downtime was 10-15 minutes)
  • compress the data (tar -czvf mysqldata.tar.gz ~/mysqldata)
  • copy the compressed file to new server

New Server

  • install mysql (don't start)
  • unzip compressed file (tar -xzvf mysqldata.tar.gz)
  • move contents of mysqldata to the datadir
  • Make sure your innodb_log_file_size is same on new server, or if it's not, don't copy the old log files (mysql will generate these)
  • Start mysql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment