Home Web Hosting How to Import a Large Database into MySQL

How to Import a Large Database into MySQL

Last updated on Jun 12, 2025

When dealing with large databases, the standard phpMyAdmin tool in cPanel might not be the most reliable option for uploading. In such cases, it's more efficient to import the database manually using an SSH (Secure Shell) session. This guide will walk you through the process.

Preparing for the Import

Before you begin, you'll need to gather some essential details:

  • Database Dump File: This is the file containing your database data, often with a .sql extension. You can upload this file into your home directory using FTP.
  • Database Name: The name of the database you want to import into. The database must already exist, so create it if you haven't already done so.
  • Database Username and Password: A valid database username (and password) that has full permissions to the database.

Importing Your Database

Once you have successfully opened an SSH session, you can import your database using the following command:

mysql -u yourusername -p yourdatabase < yourdumpfile.sql

 Here's what each part of the command means:

  • mysql: This is the command to run mysql in interactive mode.
  • -u yourusername: This is the MySQL user that you configured in cPanel beforehand.
  • -p: This tells MySQL that you will enter a password manually.
  • yourdatabase: This is the full name of the database you want to import into.