> ## Documentation Index
> Fetch the complete documentation index at: https://help.noxity.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Import a Database

> Upload a SQL or compressed dump into a cPanel MySQL database, including the workaround for files larger than the phpMyAdmin upload limit.

Importing a SQL dump is how you restore a database from a backup, migrate from another host, or stand up a copy of production for testing. phpMyAdmin's **Import** tab handles dumps up to about 50 MB straight from the browser. For larger files, there's a workaround at the bottom of this page.

## Before you begin

* The target database must already exist. Create it through [Manage My Databases](/web-hosting/cpanel/database-management/manage-databases) or [Database Wizard](/web-hosting/cpanel/database-management/database-wizard) first.
* If the dump contains `CREATE DATABASE` or `USE` statements with the original database name, edit them out. Your prefixed name won't match the dump's name.
* An empty target database is best. Importing into a non-empty one usually fails on duplicate keys.

## Import a small dump (under 50 MB)

<Steps>
  <Step title="Pick the target database from the left tree">
    Click the database name. Don't click into a specific table. The import goes at the database level.
  </Step>

  <Step title="Open the Import tab">
    Top of the page, between **Export** and **Operations**.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/noxity/images/cpanel/database-management/phpmyadmin/import/page-light.png" alt="phpMyAdmin Import tab with file picker" className="block dark:hidden" />

      <img src="https://mintlify.s3.us-west-1.amazonaws.com/noxity/images/cpanel/database-management/phpmyadmin/import/page-dark.png" alt="phpMyAdmin Import tab with file picker" className="hidden dark:block" />
    </Frame>
  </Step>

  <Step title="Pick the file">
    Click **Choose File** and select your `.sql`, `.sql.gz`, or `.sql.zip` file. Compressed dumps are decompressed automatically.

    Leave **Format** on `SQL`. Leave the other options at defaults unless you have a reason to change them.
  </Step>

  <Step title="Click Go">
    The file uploads, then phpMyAdmin runs through it statement by statement. A green confirmation appears on success, with the count of queries executed.

    Errors stop the import and show the line number. Fix the dump and try again.
  </Step>
</Steps>

## Import a large dump (over 50 MB)

phpMyAdmin's web upload is capped to keep the front-end fast. Files larger than that need a different route.

<Tabs>
  <Tab title="File Manager + Import (no SSH)">
    Works on every plan.

    <Steps>
      <Step title="Compress the dump">
        On your laptop, compress the `.sql` to `.sql.gz` (a 200 MB SQL file usually shrinks to 30–40 MB). On macOS or Linux: `gzip yourfile.sql`. On Windows: 7-Zip → "Add to archive" → `.gz`.

        If the compressed file is still over 50 MB, jump to the SSH option below.
      </Step>

      <Step title="Upload to the cPanel home directory">
        Open [File Manager](/web-hosting/cpanel/file-management/file-manager), go up to your home directory (the path that ends in `/home/youruser`), and upload the `.sql.gz` file.
      </Step>

      <Step title="Run the import from phpMyAdmin">
        Go back to phpMyAdmin → target database → **Import** tab. Scroll to **File to import**. There's a second option below the upload widget called **Web server upload directories** with a dropdown of files in your home directory. Pick your file there.

        Click **Go**. Same outcome as a small import, but the file is read from disk on the server instead of uploaded through the browser.
      </Step>
    </Steps>
  </Tab>

  <Tab title="SSH + mysql command (Standard / Power)">
    Faster and more reliable for very large dumps. Requires [SSH access](/web-hosting/cpanel/security-settings/ssh-keys/ssh-keys-example).

    <Steps>
      <Step title="Upload the dump">
        Use SCP, SFTP, or [Web Disk](/web-hosting/cpanel/file-management/web-disk) to put the file in your home directory.
      </Step>

      <Step title="SSH in and run mysql">
        ```bash theme={}
        ssh username@hostname.web.systeminterface.net
        mysql -u username_dbuser -p username_targetdb < ~/yourfile.sql
        ```

        Or for a gzipped dump:

        ```bash theme={}
        gunzip < ~/yourfile.sql.gz | mysql -u username_dbuser -p username_targetdb
        ```

        You'll be prompted for the database user's password. The import streams in directly with no upload limit.
      </Step>
    </Steps>
  </Tab>
</Tabs>

## Common issues

<AccordionGroup>
  <Accordion title="MySQL server has gone away">
    The dump contains a single statement larger than `max_allowed_packet`. Most often it's a long `INSERT` with thousands of rows.

    Fix: re-export the dump with the source tool's "extended insert" turned off, or with smaller batch sizes. In `mysqldump`, that's `--skip-extended-insert` or `--max-allowed-packet=64M`. The default packet limit on Noxity hosting is 64 MB.

    See the [MySQL reference for this error](https://dev.mysql.com/doc/refman/8.0/en/gone-away.html).
  </Accordion>

  <Accordion title="#1062 Duplicate entry for key 'PRIMARY'">
    The target database already has rows with the same primary key as the dump. Either drop the existing tables first (Operations tab → **Empty the table (TRUNCATE)**) or import into a freshly-created database.
  </Accordion>

  <Accordion title="#1064 You have an error in your SQL syntax">
    The dump was made with a newer MySQL version than the server runs. Look at the line shown. It's almost always `utf8mb4_0900_ai_ci` collation or `DEFINER=` clauses from MySQL 8 on a MySQL 5.7 / MariaDB target.

    Fix: re-export with `--compatible=mysql41` (mysqldump) or run search-and-replace on the dump to swap `utf8mb4_0900_ai_ci` for `utf8mb4_unicode_ci`.
  </Accordion>

  <Accordion title="Browser tab times out before import finishes">
    Large imports can take longer than the browser is willing to wait. The server keeps running. Check the database after a few minutes and see if it's populated. If not, use the SSH route, which doesn't have a browser timeout.
  </Accordion>

  <Accordion title="#1153 Got a packet bigger than 'max_allowed_packet'">
    Same root cause as "MySQL server has gone away": a single statement is too long. Same fix.
  </Accordion>
</AccordionGroup>

## Need a hand?

<CardGroup cols={2}>
  <Card title="Open a ticket" icon="life-ring" href="https://members.noxity.io/submitticket.php">
    Best for anything that needs an account check or a config change on our end.
  </Card>

  <Card title="Live chat" icon="messages" href="https://noxity.io/contact">
    Faster for quick questions during business hours.
  </Card>
</CardGroup>
