How to import a large MySQL database via SSH
phpMyAdmin is fine for smaller databases, but large imports can time out. Importing over SSH is faster and more reliable.
- Create the database and user in cPanel (see How to create a MySQL database).
- Upload your .sql file to your home directory using File Manager or SFTP. Compressed files (.sql.gz) save time.
- Connect via SSH (see How to connect via SSH).
- Run:
mysql -u cpuser_dbuser -p cpuser_dbname < backup.sql
For a compressed file:
gunzip < backup.sql.gz | mysql -u cpuser_dbuser -p cpuser_dbname
- Enter the database user's password when asked. The terminal shows nothing until the import finishes.
If it fails
- If the dump contains
CREATE DATABASE or USE lines near the top naming a different database, remove or comment them out. - "Access denied" means the user isn't assigned to the database or the password is wrong.
- Delete the .sql file once done.
Related Articles
How to connect to your hosting account via SSH
SSH (Secure Shell) gives you command-line access to your hosting account, which is useful for tools such as WP-CLI, Composer and Git, or for importing large databases. SSH on our servers uses key-based authentication on port 9284. Step 1: Create a ...
How to create a MySQL database in cPanel
Most website software (WordPress, Joomla, shops) needs a database. Quickest way: MySQL Database Wizard In cPanel, open Database Wizard in the Databases section. Enter a database name and click Next Step. Create a database user with a strong password ...
How to connect to a MySQL database using PHP
Before you start Create a database and a user in cPanel (see How to create a MySQL database in cPanel) and note: The database name and username – cPanel adds your account username as a prefix, e.g. cpuser_shop and cpuser_shopuser The user's password ...
How to send WordPress emails via SMTP
In WordPress, go to Plugins › Add New Plugin, search for WP Mail SMTP and install and activate it. Go to WP Mail SMTP › Settings. Set From Email to a mailbox on your domain and tick Force From Email. Under Mailer, choose Other SMTP. Enter: SMTP Host: ...
How to transfer emails using Outlook
If you're moving email from another provider and the old mail isn't being migrated for you, Outlook can copy it across. Step 1: Add both accounts Add your old email account and your new Managed Web mailbox to Outlook, both using IMAP. Step 2: Copy ...