InMotion Hosting Support Center

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. For our shared servers you may need to use Putty in order to connect.

Importing a Database via SSH

  1. Make sure you have your database created and a user attached to it. Please remember to copy or write down the information as you will need it in step 5.
  2. Upload your SQL file to the server by either using the 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.
  3. Log into your server via SSH.
  4. 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:
    cd /home/userna5/public_html
  5. 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.
    mysql -p -u userna5_user userna5_db < yoursqlfile.sql
  6. 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. If you had any issues along the way please let us know by commenting below.

Was this article helpful?
Continued Education in Course cPanel
You are viewing Section 27: How to Import MySQL Databases in Command Line
Section 28: Preventing the "Index Of" listing page using the Index Manager

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Support Center Login

Our Login page has moved, Click the button below to be taken to the login page.

n/a Points
2018-11-07 10:30 am

I tried running this command for a large sql file but get  No such file or directory.  How can I find where the mysql files are?


42,447 Points
2018-11-07 11:23 am
Unfortunately, this command requires that you know where you have saved your exported SQL file. Generally, you have an exported file that you save on the web server, then you can reference it from the command line. The information in the article above uses the location of the file based on having uploaded the SQL file to the public_html folder on your Web server.

Post a Comment

Email Address:
Phone Number:

Please note: Your name and comment will be displayed, but we will not show your email address.

3 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?


Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail:
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!