Skip to content

Instantly share code, notes, and snippets.

@llagerlof
Created September 3, 2018 13:14
Show Gist options
  • Select an option

  • Save llagerlof/ef1395571e1c4ec11aea1b49a4f617d1 to your computer and use it in GitHub Desktop.

Select an option

Save llagerlof/ef1395571e1c4ec11aea1b49a4f617d1 to your computer and use it in GitHub Desktop.
How to duplicate a entire MySQL database to another one in the same MySQL server
# Use the -p flag if needed:
mysqldump -u root db_with_data | mysql -u root db_empty
# If you have the error
# "mysqldump: Got error: 1449: The user specified as a definer ('someuser'@'someaddress')
# does not exist when using LOCK TABLES",
# create the missing user:
mysql> create user 'someuser'@'someaddress';
# Run the dump:
mysqldump -u root db_with_data | mysql -u root db_empty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment