Articles on: cPanel Tutorial

How to Import MySQL Databases in Command Line

In this tutorial, we will go over the steps on how to import MySQL databases within your command line interface.

Using this method is just as easy as importing via the PHPMyAdmin software.

However within the command line you may import SQL files over 50MB and require access to the server via SSH.

Importing a Database via SSH

Make sure you have your How to Add and Assign User to MySQL Database to it.
Please remember to copy or write down the information as you will need it in step 5.

Upload your SQL file to the server by either using the How to Upload File Using File Manager or a FTP Client.
It does not matter where you upload it, just remember its location as you will need it later in the steps.

Login to your server via SSH (or using Putty)

Navigate to where you uploaded the .sql file.
For example if you uploaded the file to your public_html folder you would run the following command:

Use the command below while replacing userna5_db with your cPanel username and database name, as well as userna5_user with your cPanel user and database user.

This will prompt you for a password, here you will enter the password you used when creating the mysql user and attaching it to the database.

Congratulations you have now imported your SQL file into your database!

Important Note: Normal shared hosting plans are unable to use the database import method above.

It's only available for Reseller (WHM), VPS, Cloud Server and Dedicated server clients.

Kindly submit a support ticket to our technical team if you're unable to perform the database import using the SSH method above.

Updated on: 16/08/2018

Was this article helpful?

Share your feedback


Thank you!