# Importing remote database

{% hint style="warning" %}
Currently, **only SSH protocol is supported**!
{% endhint %}

To import database from remote server use[ import-db](/getting-started/available-commands/import-db.md) command with `--remote-db` option:

{% tabs %}
{% tab title="yarn" %}

```bash
yarn import-db --remote-db ssh://my-username@my-server.com
```

{% endtab %}

{% tab title="npm" %}

```
npm run import-db -- --remote-db ssh://my-username@my-server.com
```

{% endtab %}
{% endtabs %}

CMA will connect via ssh to your server, create 2 dump files (`dump-0.sql` and `dump-1.sql`), download them to your projects root folder, merge them into single `dump.sql` and import to your local instance with applied fixes.

### Is there a reason to use import from remote db when possible?

There is a good reason for it!\
The dump file created by this command is much smaller than dump files that are created the usual way.\
This is because we omit **orders** and **customers** data when we're creating dump file so it comes in a much smaller size.

For example, a dump from a database could weigh 2.7GB, now using this import feature size will be reduced to 4MB.

### Why 3 dump files?

The reason to make 3 dump files is simple: [mysqldump](https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html) utility cannot make dump files with only a few tables without data, --no-data option is a boolean so we have only 2 options, either include data or not.

`dump-0.sql` file contains **all** the database tables **with data**, except for the order and customer-related tables.\
`dump-1.sql` file contains **only** orders and customer-related table structures, **without data**.\
`dump.sql` file is made from concatenating `dump-0.sql` with `dump-1.sql` , which are downloaded from your remote server, so it's **a full dump file**.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.create-magento-app.com/usage-guide/importing-database/importing-remote-database.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
