---
title: "How to import a database through shell"
description: "When you are importing a database over 50MB, you will run into the limitation in your PhpMyAdmin that prevents you from importing a database over 50MB. On shared servers you can try installing your..."
url: https://www.inmotionhosting.com/support/website/import-database-through-shell/
date: 2013-04-30
modified: 2021-08-16
author: "InMotion Hosting Contributor"
categories: ["Website", "Working with Databases"]
type: post
lang: en
---

# How to import a database through shell

When you are importing a database over 50MB, you will run into the limitation in your PhpMyAdmin that prevents you from [importing a database over 50MB](/support/website/upload-large-database-over-50-mb/). On shared servers you can try [installing your own PhpMyAdmin](/support/website/installing-phpmyadmin-on-your-account/) to import it or you will need to contact [tech support](/support/amp/how-to-get-great-technical-support/) to import it for you.

This article will explain how to import a database via SSH.

[![text](https://www.inmotionhosting.com/support/wp-content/uploads/2013/04/edu_mysql_import-database-shell_import-database-1.png)](/support/wp-content/uploads/2013/04/edu_mysql_import-database-shell_import-database-1.png)

**Important!** You must first have a [database created](/support/) like the image to the right.

## Steps to Import a database through shell

1. SSH into your server using the correct steps for your hosting plan – [shared](/support/server/ssh/shared-reseller-ssh/) or [VPS/Dedicated](/support/server/ssh/how-to-login-ssh/).
2. **Go to the directory** your backup *.sql* file is located in. For example, if your database backup is named *new_databse.sql* in your cPanel home directory for *userna5*, you will change to that directory like the following command. cd /home/userna5
3. **Check the directory** for your *.sql* file by typing `ll`. You should see an output similar to below: root@vps#### [/home/userna5]# ll total 328 drwx--x--x 21 userna5 userna5 4096 Apr 30 15:40 ./ drwx--x--x 17 root root 4096 Dec 6 16:28 ../ lrwxrwxrwx 1 userna5 userna5 34 Apr 14 2011 access-logs -> /usr/local/apache/domlogs/userna5/ drwxr-xr-x 2 userna5 userna5 4096 Oct 9 2012 bin/ -rw-r--r-- 1 root root 201467 Apr 30 15:40 new_databse.sql -rw-r--r-- 1 userna5 userna5 4264 Apr 30 12:10 error_log drwxr-x--- 3 userna5 mail 4096 Feb 22 09:02 etc/ drwxr-x--x 9 userna5 userna5 4096 Feb 21 09:53 mail/ drwxr-xr-x 3 userna5 userna5 4096 Mar 27 11:26 perl/ lrwxrwxrwx 1 userna5 userna5 14 Mar 27 11:26 perl5 -> perl/usr/local/ drwxr-xr-x 9 userna5 userna5 4096 Oct 9 2012 php/ drwxr-xr-x 3 userna5 userna5 4096 Apr 14 2011 public_ftp/ drwxr-x--- 47 userna5 userna5 4096 Apr 26 13:17 public_html/ drwxr-xr-x 10 userna5 userna5 4096 Apr 23 11:30 tmp/ lrwxrwxrwx 1 userna5 userna5 11 Apr 14 2011 www -> public_html/
4. Next you can Import the database. **user_name:** This is your cPanel username or the database user you created and added to the database. **data_base:** This is the name of the database. In this example its *userna5_tester*. **new_databse.sql:** This is the name of the database you want to import into your empty database on your server. The general syntax for the command is as follows: mysql -p -u **user_name** **data_base** < **new_databse.sql** In this example we will use the cPanel Username. Hit **Enter**. mysql -p -u **userna5** **userna5_tester** < **new_databse.sql**
5. You will be asked to enter your password like the following. **Enter the users password**. (For the cPanel user you use the cPanel password. If you added a user to the database, you will use that users password.) root@vps#### [/home/userna5]# mysql -p -u userna5 userna5_tester < new_databse.sql Enter password: [![text](https://www.inmotionhosting.com/support/wp-content/uploads/2013/04/edu_mysql_import-database-shell_import-database-2.png)](/support/wp-content/uploads/2013/04/edu_mysql_import-database-shell_import-database-2.png) When the database is finished you will get the prompt again. **Check your database** in your cPanel. You should see Megabytes taken in the size column like the image to the right.
