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.

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

  1. Create a database dump file from the command line by using either Drush or mysqldump:

    • 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 that Drush has the required permissions to save files in that directory.
      For more information, see the Drush documentation.

    • 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

      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.
  2. Using SFTP, scp, or rsync, copy the database dump file to your Acquia Cloud server. For example, using scp, use a command in this form:

    scp [db_filename].sql.gz [site].[env]@[server]:./[db_filename].sql.gz

    where:

    • [db_filename] is the path and file name you choose to give your database dump file. Be sure to keep the .sql.gz extension.
    • [site] is the site name, the string that precedes .dev under SSH address listed in the Acquia Cloud interface on the Servers page for the environment.
    • [env] is the environment you want to connect to (usually dev for the Development environment).
    • [server] is the name of your Acquia Cloud server, which is listed on the Servers page of the Acquia Cloud interface. For example: ded-1234.network.hosting.acquia.com.

    For example:

    scp abc_db.sql.gz [email protected]:./abc_db.sql.gz
  3. The easiest way to import a database dump file from the command line is to connect to your Acquia Cloud server with SSH and use the drush ah-db-import command. This command takes the following form:

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

    where:

    • [site] is the name of your application on Acquia Cloud.
    • [env] is the environment into which you're importing your database. Acceptable values are dev (Development), test (Staging), and prod (Production).

    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

    This presumes you have installed the Acquia Cloud Drush aliases integration. If not, you need to use the --site=[site] and --env=[env] arguments with the ah-db-import command. For example:

    drush @example.test ah-db-import ~/dbdump.sql.gz --site=example --env=test

    For more information, read Importing using Drush.

Importing a database for a Drupal multisite installation

To import a database for a Drupal multisite installation, run the ah-db-import command on your Acquia Cloud server:

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

where:

  • [site] is the name of your application on Acquia Cloud.
  • [env] is the environment into which you're importing your database. Acceptable values are dev (Development), test (Staging), and prod (Production).
  • [db_name] is 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.

For more information, see About Drupal multisite installations.

Set up database connections

After you have imported your database, go to the Acquia Cloud Databases page. Click PHP to display the require statement for your database, add that statement at the end of the settings.php file in your /sites directory, and 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. This allows you to use the same settings.php file in each of your Acquia Cloud environments.

Next step

After you import your database, you can import files using SFTP, scp, or rsync.

Contact supportStill need assistance? Contact Acquia Support