Databases1 min readUpdated

Import or export a large database

Commands for dumps and imports over SSH that work for databases of any size, and the safe way to replace a store's database.

For anything above a few hundred megabytes, use SSH. It has no upload limit and no timeout.

Export

mariadb-dump --single-transaction --quick --routines \
  -u USER -p DATABASE | gzip > ~/backup-$(date +%F).sql.gz

Import

gunzip < dump.sql.gz | mariadb -u USER -p DATABASE

Upload the file by SFTP to the application's folder first. The user and database are on the Databases tab; reset the password there if you do not have it.

Magento dumps from another host often contain DEFINER clauses for a user that does not exist here. Remove them before importing:

gunzip < dump.sql.gz | sed -E 's/DEFINER=`[^`]+`@`[^`]+`//g' | mariadb -u USER -p DATABASE

Importing into a database that a live store uses replaces its data. Put the store in maintenance mode first, or import into a new database and switch the store's configuration to it.

Did this solve it? If not, tell us what you see and we look at your server.

Open a ticket

Still stuck? Ask a person.

Tickets go straight to the engineers who run ShopWhizzy servers. Tell us the store, what you see and when it started, and we take it from there.