---
title: "How to Import MySQL Databases in Command Line"
description: "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,..."
url: https://www.inmotionhosting.com/support/website/how-to-import-mysql-databases-in-command-line/
date: 2015-12-16
modified: 2023-12-14
author: "InMotion Hosting Contributor"
categories: ["Linux", "Website", "Working with Databases"]
type: post
lang: en
---

# 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, the command line interface is preferred when you need to import SQL files over 50MB. For our shared servers you may need to [use Putty in order to connect](/support/server/ssh/shared-reseller-ssh/).

## Importing a SQL Database via SSH

1. Make sure you have your [database created](https://www.inmotionhosting.com/support/edu/cpanel/create-mysql-database/) and a [user attached](/support/edu/cpanel/create-database-user/) 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](/support/edu/cpanel/using-file-manager-in-cpanel/) or a [FTP Client](/support/website/ftp/configuring-your-site-in-filezilla/). 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](/support/server/ssh/how-to-login-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. Next, use the command below to import the database. Replace *userna5_db* with your cPanel username and database name, and replace *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 that is associated with 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.

**Scalable VPS Infrastructure, Fully Managed**

When shared hosting can’t handle your traffic, VPS delivers dedicated resources that scale with demand. Our team manages the technical complexity while you manage your business.

![check mark](https://design.inmotionhosting.com/assets/icons/standard/check-blue.svg)NVMe Storage    ![check mark](https://design.inmotionhosting.com/assets/icons/standard/check-blue.svg)High-Availability    ![check mark](https://design.inmotionhosting.com/assets/icons/standard/check-blue.svg)Ironclad Security    ![check mark](https://design.inmotionhosting.com/assets/icons/standard/check-blue.svg)Premium Support

[VPS Hosting](https://www.inmotionhosting.com/vps-hosting?mktgp=t&irgwc=1&affiliates=5001860&utm_campaign=Jumbotron&utm_source=supportcenter&utm_medium=cta&utm_term=vps-cta2)
