< All Topics
   

How to import a database via SSH is one of the fastest and most reliable ways to upload large SQL files to your hosting account. This method is especially useful when phpMyAdmin times out or fails due to file size limits.

Hosted.com® provides SSH access on supported hosting plans, allowing you to securely import databases directly from the command line.

This guide explains how to import a MySQL database via SSH using cPanel credentials.

When Should You Import a Database via SSH?

Using SSH is recommended when:

  • Your database file is large (typically over 50MB).
  • phpMyAdmin import fails or times out.
  • You’re migrating a website or restoring a backup.
  • You need faster, more stable database imports.

Requirements:

Before you begin, ensure that:

  • SSH access is enabled on your Hosted.com® hosting plan.
  • You have your cPanel username and password.
  • The database and database user already exist in cPanel.
  • You have the.sql file ready on your local computer.

How To Import A Database Via SSH In cPanel

Step 1: Upload the Database File to Your Hosting Account

1. Login to your Hosted.com® account.

2. Open cPanel for the domain you’re working on.

3. Go to File Manager.

4. Navigate to your home directory or a temporary folder (e.g. /home/username/).

5. Upload your.sql file.

Step 2: Connect to Your Server via SSH

You can connect using:

  • Terminal (Linux/macOS).
  • PuTTY (Windows).

Use the following command:

ssh username@yourdomain.co.za

Enter your cPanel password when prompted.

Step 3: Import the Database

Once connected, run this command:

mysql -u database_user -p database_name < backup.sql
EXAMPLE:
mysql -u myuser_wp -p mydatabase_wp < backup.sql
  • Press Enter.
  • Enter the database user password when prompted.
  • Wait for the command to complete.

If the import is successful, no confirmation message will appear.

Step 4: Verify the Import

To confirm the import:

1. Log back into cPanel.

2. Open phpMyAdmin.

3. Select the database.

4. Check that tables and data are present.

Additional Information

  • Importing a database via SSH bypasses browser-based limitations found in tools like phpMyAdmin, making it the most reliable option for handling large SQL files, complex table structures, or databases containing millions of rows without risking timeouts or incomplete imports.
  • When importing a database into an existing environment, it is important to ensure that table prefixes, character sets, and collations match the original database configuration, as mismatches may lead to broken site functionality or unexpected encoding issues.
  • If you are restoring a backup over an existing database, all existing tables with matching names will be overwritten, which is why Hosted.com® strongly recommends exporting a full backup of the current database before running an import command.
  • Database imports performed via SSH require that the database user has full privileges (SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, and INDEX), as limited permissions can cause silent failures during the import process.
  • Once the import is completed successfully, removing the SQL file from your hosting account is considered a best security practice, as leaving database dumps accessible on the server can pose a security risk if file permissions are misconfigured.

Login to Hosted.com® Account

1. Go to the Hosted.com® website Account Login page.

2. Enter your Email and Password and click the Sign In button.

How To Import A Database Via SSH In cPanel - Hosted.com® Sign In Webpage

3. You will see the Hosted.com® Dashboard, displaying the Manage Account menu on the left and your Account Information, Account Overview and Open Support Tickets on the right.

Hosted.com® Dashboard Manage Services

Login to cPanel from your Hosted.com® Dashboard

4. Click on Manage Services to view the sub-dropdown menu and select the hosting package for the domain you want to work with – in our example we are using WordPress Hosting.

5. Click the Manage button to the right of the domain name you want to access.

Hosted.com® Dashboard WordPress Hosting

6. The display will now show Product Information, Quick Manage, Resource Usage and Site Statistics for that domain name.

Hosted.com® Dashboard Manage Services

7. Under Product Information, scroll down to Control Panel, which will display cPanel to the right, and click on the Login button.

Hosted.com® cPanel Dashboard

8. The cPanel Dashboard will now be displa

Was this article helpful?
Please Share Your Feedback
How Can We Improve This Article?