Tutorial: Importing a database¶
The goal of this tutorial is to migrate an old “non-Elastycloud” database into our platform.
This tutorial will wipe your deployments database and replace it with your own database. It is highly recommended that you try this out on a staging deployment first. This is not an officially supported feature yet, you may encounter issues during this guide that is specific to your case, leaving your deployment in a failed state.
- You have to be a registered partner of Elastycloud
- You need to have an account and be able to sign in to Console
- You need an existing deployment with your own package matching your current stores code.
- You need to have a local installation of the above package running so you can prepare a database dump
- You need to have a toolkit running
For the site to work after the import, it is important that you take a database-dump from an environment that is running the same codebase that is CURRENTLY deployed.
When exporting a Magento2 database dump you have to remove all definers from your *.sql dump. These definers have a reference to your old mysql credentials.
An example of a definer exported from another system might look like this buried in the mysql-dump.
This MYSQL user will not exist in our system so your import will fail with a permission error. To create a clean mysqldump you can can run the following command:
mysqldump ... | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' > new-clean-dump.sql
Or if you already have an existing dump:
sed -i 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' dump-you-made-before.sql
Leaving definers in your database dump WILL result in a permission error during import
Make note of your elastycloud domain name.
Increase the toolkit lifetime inside your toolkit panel at the top right
PhpMyAdmin frontend may timeout with a 504 during long imports but it keeps on working in the background
Inside Console go to and click edit on your deployment.
Scroll all the way down and make note of your domain here.
Save your elastycloud core_config_data for reference
- Go to your toolkit, and click Database
- Using the phpmyadmin interface go to the
- Click export, Export with the default settings and save it locally for reference
- Confirm that your core_config_data dump contains SQL
- Do the same for the tables
Import the database¶
Following below steps will delete data in your database and render your deployment broken, until you complete the import.
Please remember to disable foreign key checks when importing a database. Forgetting this may lead to looping and unwanted behaviour.
Go to your toolkit, and click Database
Click Your database name to the left and scroll all the way down, click check all and DROP them. This may take a little while.
Click the IMPORT tab, click CHOOSE FILE and select your complete GZIPPED magento2 database dump from your other provider and click import.
Make sure your cleaned it of DEFINERS as detailed above.
This may take a while.
Restore Base URL¶
- Click on the table
core_config_dataand then on the SEARCH tab.
- In the value textbox type in “http%” and hit search
- Update all “base_url” entries so they match the domain name you took note of in the preparations above.
Take care to include
https://and a slash at the end
- Make sure the path “admin/url/custom” is set the same as before, and “admin/url/use_custom” is set to 1
- Import the data for tables
elastycloud_ftp_accountsyou exported earlier
Restore Asset management settings¶
These settings must be the same as specified in your elastycloud.yaml file in the root of your repository. If you have not made any changes in asset management in that file it safe to use the defaults below.
- Delete all asset management settings from core_config_data, run this query:
DELETE FROM `core_config_data` WHERE `path` IN ( "dev/css/merge_css_files", "dev/css/minify_files", "dev/js/enable_js_bundling", "dev/js/merge_files", "dev/js/minify_files", "dev/static/sign" )
- Add the correct values, run this query:
INSERT INTO `core_config_data` (scope,scope_id,path,value) VALUES ("default","0","dev/css/merge_css_files","1"), ("default","0","dev/css/minify_files","1"), ("default","0","dev/js/enable_js_bundling","1"), ("default","0","dev/js/merge_files","1"), ("default","0","dev/js/minify_files","0"), ("default","0","dev/static/sign","1");