Importing Large MySQL Databases (Firstserv Guide)

If your database is too large to upload via phpMyAdmin in cPanel or Plesk, using SSH (Secure Shell) is the most reliable method.

Large imports via phpMyAdmin can fail due to timeouts or connection issues. Importing via SSH avoids these limits and is faster for big databases.


Before You Begin

Make sure you have:

  • ✅ Your database backup file (usually .sql)
  • ✅ The file uploaded to your server (e.g. in your home directory via FTP or File Manager)
  • ✅ An existing database (created via cPanel or Plesk)
  • ✅ A database user with full permissions
  • ✅ SSH access enabled on your hosting/server

Step 1: Connect via SSH

  • Connect to your server using an SSH client:
    • Windows: PuTTY or terminal
    • macOS/Linux: Terminal

👉 You should now have an active command-line session.


Step 2: Run the Import Command

Use the following command format:

 
 
 
 
 
 
Shell
 
 
mysql -u DB_USER -p DB_NAME < dumpfile.sql
``
 
 

Example

 
 
 
 
 
 
Shell
 
 
mysql -u firstserv_user -p firstserv_db < mybackup.sql
 
 

What Each Part Means

  • mysql → Starts the MySQL command-line tool
  • -u DB_USER → Your database username
  • -p → Prompts you to enter your password
  • DB_NAME → The database you’re importing into
  • < → Redirects the file into MySQL
  • dumpfile.sql → Your backup file

Important Notes

  • If your file is in another folder, include the full path:
 
 
 
 
 
 
Shell
 
 
mysql -u firstserv_user -p firstserv_db < /home/user/backups/mybackup.sql
 
 
  • After running the command:
    • Enter your database password
    • Press Enter to begin the import

Step 3: Wait for Completion

  • Large databases may take time to import
  • ✅ It’s normal for the process to take several minutes

⚠️ Do not close the SSH connection until it finishes


Common Issues & Fixes


1. Import Fails or Stops

✅ Solution:

  • Delete the database in cPanel/Plesk
  • Recreate it
  • Run the import again

2. Database Already Exists Errors

Some .sql files contain lines like:

 
 
 
 
 
 
SQL
 
 
CREATE DATABASE dbname;
USE dbname;
 
 
 

✅ Fix:

  • Remove these lines, or
  • Comment them out using:
 
 
 
 
 
 
SQL
 
 
-- CREATE DATABASE dbname;
-- USE dbname;
 
 
 

3. Permission Errors

  • Ensure your database user has:
    • ✅ Full privileges (ALL PRIVILEGES)

cPanel vs Plesk Notes

  • ✅ In cPanel:
    • Create databases via MySQL Databases
  • ✅ In Plesk:
    • Create databases via Databases → Add Database

👉 The SSH method works the same in both environments.


Summary

  • Use SSH for importing large MySQL databases
  • Upload your .sql file to your server
  • Run the mysql command with your credentials
  • Wait for the import to complete
  • Troubleshoot errors by checking database setup and file contents

Need Help?

If you're unsure about SSH access or encounter errors during import, the Firstserv support team is always happy to help guide you through the process.

 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Managing Disk Usage in cPanel

Managing Disk Usage in cPanel (Firstserv Guide) Running low on storage can be stressful—but...

Get a free Let's Encrypt SSL for your website

An SSL (Secure Sockets Layer) certificate ensures that the connection between your website...

What happens if I exceed my disk space allowance?

Disk Space & Mailbox Usage (Firstserv Guide) Managing your disk space is essential to...

Backing Up Databases via SSH

Backing Up Databases via SSH (Firstserv Guide) This guide explains how to create MySQL...

Database Not Showing in phpMyAdmin

Database Not Showing in phpMyAdmin (Firstserv Guide) If you’ve just created a new database...