# Import database dump

## `yarn import-db [dump file path]` or `npm run import-db [dump file path]`

Imports database dump into MySQL container.

{% hint style="warning" %}
Note 1: To be able to import a database dump application must be running.\
Note 2: It is recommended to run the [start](/getting-started/available-commands/start.md) command after running database import to ensure that configuration is up-to-date.
{% endhint %}

### **Command options**

#### **`-r, --remote-db`**

Imports database from the remote server.\
Currently, the following protocols are supported:

* `ssh://`

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

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

{% endtab %}

{% tab title="npm" %}

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

{% endtab %}
{% endtabs %}

Now it will connect via ssh to your server, create 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.

To learn more about this option, read the following guide:

{% content-ref url="/pages/-Mchm5W0CLqGRl1Y1PU1" %}
[Importing remote database](/usage-guide/importing-database/importing-remote-database.md)
{% endcontent-ref %}

#### `--with-customers-data`

Does not exclude customers and orders data when importing local and remote database.

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

```bash
yarn import-db ./dump.sql --with-customers-data
yarn import-db --remote-db ssh://my-username@my-server.com --with-customers-data 
```

{% endtab %}

{% tab title="npm" %}

```
npm run import-db ./dump.sql -- --with-customers-data
npm run import-db -- --remote-db ssh://my-username@my-server.com --with-customers-data
```

{% endtab %}
{% endtabs %}

If you are importing a remote database and using this option, CMA will create only one `dump.sql` file with all data inside it.

## **Usage example**:

```bash
yarn import-db ./dump.sql
... # output

# or with npm
npm run import-db ./dump.sql
... # output
```


---

# 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/getting-started/available-commands/import-db.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.
