Information for: DEVELOPERS   PARTNERS

Importing your database

Importing manually

This page describes manually importing the database of an existing Drupal application into Acquia Cloud, as part of the process of manually importing the entire application. For information about other methods of importing an application, see Importing an existing application.


The process described on this page requires you to install the Drush aliases integration for Acquia Cloud before proceeding.

To import a database using command-line tools, complete the following steps:

  1. Create a dump file of your database.
  2. Import the 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 executing either Drush or mysqldump from your Drupal directory:

  • Using Drush

    Go to the Drupal directory, and then enter the following command:

    drush sql-dump --gzip --result-file=../mysite.sql

    Drush saves the mysite.sql.gz site archive file relative to your current Drupal docroot. If the command displays error messages, ensure Drush has the required permissions to save files in the docroot directory.

    For more information, see the Drush documentation.

  • Using mysqldump

    Make a database dump file from your existing database using the mysqldump command-line tool.

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


    • [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. Ensure you keep the .sql.gz extension.

After you create the database dump file from your existing database, import the database dump file into the new database.

Importing your database dump file

To import a database dump file into your subscription on Acquia Cloud, perform the following steps:

  1. Connect to your Acquia Cloud server with SSH.

  2. Upload your database backup to Acquia Cloud, using commands similar to the examples provided at Downloading backups with command line tools. Ensure you alter the command to upload from your local computer to Acquia Cloud.

  3. Import your database dump file using either of the following processes:

    • To import a single website’s database dump file, use the Drush ah-db-import command, altering the command as described in the Variable legend:

      drush @[site].[env] ah-db-import [/path/to/db/dump/file]

      For example, if you are importing a database into the Staging environment of an application named example:

      ssh [email protected] drush @example.test ah-db-import ~/dbdump.sql.gz
    • To import a database for a Drupal multisite installation, use the previous procedure with the following ah-db-import command, altering the command as described in the Variable legend, on your Acquia Cloud server:

      drush @[site].[env] ah-db-import --db=[db_name] --drop --force [/path/to/db/dump/file]

      For more information, see About Drupal multisite installations.

After importing your database dump file, connect your Drupal installation to the database.

Variable legend

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

  • [site] – The name of your application on Acquia Cloud.
  • [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 site name is example, your default database name will probably be example, and you should use that rather than an environment-specific name like exampledev or exampletest.

Setting up database connections

After your have imported your database, you can connect your Drupal installation to the database you have imported by performing the following steps:

  1. Sign in to Acquia Cloud.
  2. Go to the Acquia Cloud Databases page.
  3. Click PHP to display the require statement for your database.
  4. Add the previous require statement at the end of the settings.php file in your /sites directory.
  5. Commit or push the changed file to your application’s Acquia Cloud code repository.

The database require statement causes your application to use a unique database for each Acquia Cloud environment, which allows you to use the same settings.php file in each of your Acquia Cloud environments.

You can now import files using Secure File Transfer Protocol (SFTP), Secure Copy (SCP), or rsync.