# How to import a large MySQL database via SSH

> If phpMyAdmin times out or refuses your SQL file because it is too large, importing via SSH is the reliable alternative. This guide walks you through uploading your dump file safely and running the import from the command line.

Source: https://www.kualo.com/knowledgebase/cpanel-databases/how-to-import-a-large-mysql-database-via-ssh
Updated: 2026-06-13

---

If phpMyAdmin times out or refuses your SQL file because it is too large, importing via SSH is the reliable alternative. This guide walks you through uploading your dump file safely and running the import from the command line.

## When to use this method

phpMyAdmin imposes a file size limit on uploads and runs inside a PHP process that can time out on large imports. For databases of more than a few hundred megabytes, or any import that has already timed out in phpMyAdmin, the command-line method is the practical solution. There are no upload size limits and no script timeouts to worry about.

:::info
If your SQL file is very large - several hundred megabytes or more - cPanel's File Manager is not a practical option for uploading it. File Manager is browser-based and will time out or fail on large files. Use SCP or an SFTP client as described below instead. If you have not yet set up SSH or SFTP access, this guide covers both.
:::

## Prerequisites

Before you start, make sure the following are in place.

- The destination database and a database user already exist in cPanel, and the user has been assigned to the database. If you have not done this yet, follow our guide on [how to create a MySQL database in cPanel](/knowledgebase/cpanel-databases/how-to-create-a-mysql-database-in-cpanel).
- You have SSH access to your hosting account and can log in successfully. If you are not sure how to connect, see our [getting-started guide to SSH on Kualo hosting](/knowledgebase/dev-cli/using-ssh-on-kualo-hosting-a-getting-started-guide).
- You have a SQL dump file (`.sql` or `.sql.gz`) ready on your local machine.

:::info
SSH access must be enabled on your account before you can connect. Check whether SSH is available on your plan, or [contact our support team](/knowledgebase/getting-started/how-to-create-a-support-ticket-in-mykualo) to have it enabled.
:::

## Where to store the SQL file on the server

Upload the file to a private directory inside your home folder, such as `~/db-imports/`. Do not place it *anywhere* inside `public_html` or any other web-accessible directory, because a SQL dump can contain sensitive data including passwords and personal information.

To create a dedicated import directory over SSH:

```bash
mkdir -p ~/db-imports
```

## Uploading the SQL file

Choose whichever method suits you.

**Option 1 - scp from your local machine**

Run this command in a terminal on your own computer, replacing the placeholders with your details:

```bash
scp /path/to/your-dump.sql yourusername@yourserver.kualo.net:~/db-imports/
```

Replace `yourusername` with your SSH username, `yourserver.kualo.net` with your server hostname, and `/path/to/your-dump.sql` with the local path to your file.

**Option 2 - SFTP client**

Connect to your account using an SFTP client such as FileZilla or WinSCP. Navigate to your home directory and upload the file into the `db-imports` folder you created. Your home directory is typically `/home/yourusername/`.

:::tip
If you are not sure how to connect with FileZilla, see [configuring your website in FileZilla](/knowledgebase/cpanel-files-ftp/configuring-your-website-in-filezilla) or [uploading files using FileZilla](/knowledgebase/cpanel-files-ftp/uploading-files-using-filezilla).
:::

## Running the import

### Check your database and username

On cPanel shared hosting, both the database name and the database username are prefixed with your cPanel account username. For example, if your cPanel username is `acme` and you named your database `shop`, the full database name will be `acme_shop`. The same applies to the database user: `acme_dbuser`.

Always use the full prefixed names exactly as they appear in cPanel under **MySQL Databases**. Using the short name without the prefix is the most common cause of "access denied" or "unknown database" errors.

### Run the import command

Log in to your account over SSH, then run:

```bash
mysql -u cpanelusername_dbuser -p cpanelusername_dbname < ~/db-imports/your-dump.sql
```

Replace `cpanelusername_dbuser` with your full database username, `cpanelusername_dbname` with your full database name, and `your-dump.sql` with the filename you uploaded.

You will be prompted to enter the database user password. Type it and press Enter. The cursor will not move while you type - that is expected behaviour.

If the import is large, the command will run silently for some time. Do not close the terminal until the shell prompt returns.

### Importing a compressed file

If your dump is gzip-compressed (`.sql.gz`), you can pipe it directly into MySQL without decompressing it first. This saves disk space, which matters if your account quota is tight:

```bash
gunzip -c ~/db-imports/your-dump.sql.gz | mysql -u cpanelusername_dbuser -p cpanelusername_dbname
```

:::warning
A large SQL file and the populated database both count against your account's disk quota at the same time. If you are close to your limit, [check your disk usage in cPanel](/knowledgebase/cpanel-account/how-to-use-the-disk-usage-tool-in-cpanel) first, or [contact our support team](/knowledgebase/getting-started/how-to-create-a-support-ticket-in-mykualo) before proceeding.
:::

## Verifying the import

If the command completes without printing any error messages, the import has succeeded. You can do a quick spot-check in one of two ways.

**From the command line**, log in to MySQL and check that the tables are present:

```bash
mysql -u cpanelusername_dbuser -p cpanelusername_dbname
```

Then, at the MySQL prompt:

```sql
SHOW TABLES;
```

You should see a list of tables matching your original database. Type `exit` to leave the MySQL prompt.

**From phpMyAdmin**, open the database in cPanel and browse a table or two to confirm the data looks correct. See [becoming familiar with databases in phpMyAdmin](/knowledgebase/cpanel-databases/becoming-familiar-with-databases-in-phpmyadmin) if you need a refresher on navigating phpMyAdmin.

## Tidying up

Once you are satisfied the import is complete and your application is working correctly, delete the SQL file from the server. It may contain database credentials, email addresses, or other sensitive data that should not sit on the server indefinitely.

```bash
rm ~/db-imports/your-dump.sql
```

If you created the `db-imports` directory solely for this purpose, you can remove it too:

```bash
rmdir ~/db-imports
```

---

_Source: Kualo Knowledgebase — https://www.kualo.com/knowledgebase/cpanel-databases/how-to-import-a-large-mysql-database-via-ssh · © Kualo Ltd._
