---
title: "Importing your database"
date: "2024-02-14T06:18:38+00:00"
summary: "Learn how to manually import your existing Drupal database into Cloud Platform. Follow our step-by-step guide for seamless database synchronization, dumping, and restoration using Drush or command-line tools. Ensure a smooth transition for your application."
image:
type: "page"
url: "/acquia-cloud-platform/importing-your-database"
id: "8320d9a7-af2e-4cbc-9a76-5c0759a7d3c1"
---

Table of contents will be added

This page describes manually importing the database of an existing Drupal application into Cloud Platform, as part of the process of [manually importing the entire application](../manual.html). For information about other methods of importing an application, see [Importing an existing application](/acquia-cloud-platform/create-apps/import).

Note

*   The process described on this page requires you to install the [Drush aliases integration](/acquia-cloud-platform/using-drush-aliases "Using Drush aliases") for Cloud Platform before proceeding.
*   The [current Drupal version](/service-offerings/guide/software-life-cycle#supported-drupal-version) requires Drush version 11 or later. Newer versions of Drush, that is, version 11 and later, must be installed via Composer. Acquia does not manage the update to the newer versions. For more information, see [About Drush on Cloud Platform](/acquia-cloud-platform/manage-apps/command-line/drush).

Synchronizing databases
-----------------------

If you have Drush configured for the source version of your application and your Acquia environments, you can use drush to synchronize them.  
 

### Drush 9 and later

To import a single website’s database from a drush alias source, use the [drush sql:sync](https://www.drush.org/11.x/commands/sql_sync/) command, replacing `[source]` and `[target]` with the [Drush aliases](/acquia-cloud-platform/using-drush-aliases "Using Drush aliases") for your source and target databases. Because Drush 9 or later no longer supports two remote targets, you must arrange for one Drush alias to be local by running the command from either application.

    drush sql:sync @[source] @[target]

After the import completes, run `drush @[target] cr` command to rebuild caches.

For more information, see [Use Drush to Sync Your Drupal Installations Between Multiple Environments](https://dev.acquia.com/article/use-drush-sync-your-drupal-installations-between-multiple-environments).

### Drush 8

To import a single website’s database from a drush alias source, use the [drush sql-sync](https://www.drush.org/11.x/commands/sql_sync/) command, replacing `[source]` and `[target]` with the [Drush aliases](/acquia-cloud-platform/using-drush-aliases "Using Drush aliases") for your source and remote databases:

    drush sql-sync @[source] @[target]

After the import completes, run the `drush @[target] cr` command to rebuild caches.

For more information, see [Use Drush to Sync Your Drupal Installations Between Multiple Environments](https://dev.acquia.com/article/use-drush-sync-your-drupal-installations-between-multiple-environments) on [dev.acquia.com](http://dev.acquia.com/).

Dumping and restoring databases
-------------------------------

To import a database using command-line tools:

1.  [Create a dump file](#cloud-create-db-dump-file) of your database.
2.  [Import the dump file](#cloud-import-dump-file) into your new database.
3.  Set up database connections.

Creating a database dump file
-----------------------------

To export the data stored in your website’s database, create a database dump file from the command line by running either [Drush](https://www.drupal.org/project/drush) or `mysqldump` from your Drupal directory:

### Drush 9 and later

In Drush 9 and later, a dump can’t be consistently made from aliases because it ignores output redirection. Instead, go to the source Drupal directory, and then run the following command:

    drush @[source] sql:dump --gzip --result-file=../mysite.sql

Drush saves the `mysite.sql.gz` site archive file relative to your current Drupal `docroot`. If needed, move the file to a location that has access to your target environment.

If the command returns error messages, ensure Drush has the required permissions to save files in the `docroot` directory.

If you’re not sourcing from the default site, you must specify a matching URI to allow Drush to select the correct site database.

    drush @[source] sql:dump --gzip --uri=my.source.com --result-file=../mysite.sql

For more information, see [About Drupal multisite installations](/acquia-cloud-platform/about-drupal-multisite-installations "About Drupal multisite installations").

### Drush 8

With source Drush alias available, run the following command:

    drush @[source] sql-dump --gzip > mysite.sql.gz

Drush saves the `mysite.sql.gz` site archive file relative to your current directory.

If you’re not sourcing from the default site, you must specify a matching URI to allow Drush to select the correct site database.

    drush @[source] sql-dump --gzip --uri=my.source.com > mysite.sql.gz

For more information, see [About Drupal multisite installations](/acquia-cloud-platform/about-drupal-multisite-installations "About Drupal multisite installations").

### mysqldump

Run the following command:

    mysqldump -u [db_username] -p[db_password] [db_name] | gzip > [db_filename].sql.gz

where:

*   `[db_username]` is the account user name that manages the database.
*   `[db_password]` is the password for the database account.
*   `[db_name]` is your Drupal database.
*   `[db_filename]` is the path and file name of the backed up database’s dump file. Be sure to keep the `.sql.gz` extension.

After you create the database dump file from your existing database, [import the database dump file](#cloud-import-dump-file) into the new database.

Importing your database dump file
---------------------------------

To import a database dump file into your subscription on Cloud Platform:

1.  [Connect to your Cloud Platform infrastructure with SSH](/acquia-cloud-platform/getting-started-ssh "Getting started with SSH").
2.  Upload your database backup to Cloud Platform, using commands similar to the examples provided at [Downloading backups with command line tools](/acquia-cloud-platform/downloading-database-backups-command-line "Downloading database backups from the command line"). Be sure to alter the command to upload _from_ your local computer _to_ Cloud Platform.
3.  Import your database dump file using one of the following methods:
    
    ### Drush 9 and later
    
    To import a database dump file to the default site, use the [drush sql:cli](https://www.drush.org/11.x/commands/sql_cli/) command, replacing `[target]` with the [Drush alias](/acquia-cloud-platform/using-drush-aliases "Using Drush aliases") for your target site:
    
        gunzip -c [/path/to/db/dump/file] | drush @[target] sql:cli
    
    If you’re not targeting the default site, you must include URI as a CLI option or in a custom Drush alias:
    
        gunzip -c [/path/to/db/dump/file] | drush @[target] sql:cli --uri=my.fake.site.com
    
    For more information, see [About Drupal multisite installations](/acquia-cloud-platform/about-drupal-multisite-installations "About Drupal multisite installations").
    
    ### Drush 8
    
    To import a database dump file to the default site, use the [drush sql-cli](https://www.drush.org/11.x/commands/sql_cli/) command, replacing `[target]` with the [Drush alias](/acquia-cloud-platform/using-drush-aliases "Using Drush aliases") for your target site:
    
        gunzip -c [/path/to/db/dump/file] | drush @[target] sql-cli
    
    If you’re not targeting the default site, you must include URI as a CLI option or in a custom Drush alias:
    
        gunzip -c [/path/to/db/dump/file] | drush @[target] sql-cli --uri=my.fake.site.com
    
    For more information, see [About Drupal multisite installations](/acquia-cloud-platform/about-drupal-multisite-installations "About Drupal multisite installations").
    

You can now [import files](/acquia-cloud-platform/importing-your-files "Importing your files") using Secure File Transfer Protocol (SFTP), Secure Copy (SCP), or [rsync](/acquia-cloud-platform/rsyncing-files-cloud-platform "rsyncing files on Cloud Platform").

### Variable legend

The following legend contains the values of the variables used in the previous commands.

*   `[site]`: The name of your application on Cloud Platform.
*   `[env]`: The environment into which you are importing your database. Acceptable values are `dev` (Development), `test` (Staging), and `prod` (Production).
*   `[db_name]`: The name of your database. Use the database name shown on the **Databases** page for the environment, not an environment-specific name. For example, if your [sitename](/resources/sitename-definition "Sitename definition") is `example`, your default database name will probably be `example`, and you should use that rather than an environment-specific name (such as `exampledev` or `exampletest`).