On this page
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.
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.
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.
- 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.
- You have a SQL dump file (
.sqlor.sql.gz) ready on your local machine.
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 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:
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:
scp /path/to/your-dump.sql [email protected]:~/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/.
If you are not sure how to connect with FileZilla, see configuring your website in FileZilla or 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:
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:
gunzip -c ~/db-imports/your-dump.sql.gz | mysql -u cpanelusername_dbuser -p cpanelusername_dbname
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 first, or contact our support team 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:
mysql -u cpanelusername_dbuser -p cpanelusername_dbname
Then, at the MySQL prompt:
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 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.
rm ~/db-imports/your-dump.sql
If you created the db-imports directory solely for this purpose, you can remove it too:
rmdir ~/db-imports