How to Import and Export a MySQL Database

This article provides a quick guide on how to import and export a MySQL database. We’ll be guiding you through all you need to know to run these simple tasks.

You can create MySQL databases and set up MySQL users via the MySQL databases tool available in SPanel’s User Interface.

How to Import and Export a MySQL Database

And here’s how to import and export data.

How to Import a MySQL Database

There would probably be an occasion where you’d want to import a MySQL database into your server. You can do that through either of these two waysphpMyAdmin or using the command line. Use this guide to get started.

Method 1: Using PhpMyAdmin

PhpMyAdmin is a free database management platform that allows you to control your databases via a browser-based graphical interface.

Here’s how.

Log in to your SPanel’s User Interface.

How to Import and Export a MySQL Database

Open phpMyAdmin from the Databases section on the homepage.

How to Import and Export a MySQL Database

SPanel will redirect you to the phpMyAdmin web interface. Click Import on the top menu bar.

How to Import and Export a MySQL Database

Select the file you want to import.

Before that, compress the file as gzip, bzip2 or zip, or leave it uncompressed. Save it on your computer using this nomenclature — .[format].[compression] — example,

How to Import and Export a MySQL Database

Select the file format and click on the Go button to begin the import.

How to Import and Export a MySQL Database

The process will start running, and you’ll see the imported database after completion.

Method 2: Using Command Line

Importing a MySQL database through the command line requires a secure shell (SSH) access. SSH allows you to remotely log in to your hosting account to perform tasks through text commands.

It enables webmasters to perform tasks as if they’re right in front of their servers. Follow this guide to import a MySQL database to your server remotely.

Log in to your FTP client to upload the file you want to import into the database. Let’s assume you saved the file as dbimport.sql

How to Import and Export a MySQL Database

Log in to your hosting account using SSH. 

Navigate to the directory where you uploaded the file, using the cd command.

Use this command to import the file to your database: mysql -u username -p dbname < dbimport.sql .

Username and dbname in the above command should be your database’s username and name, respectively.

How to Export a MySQL Database

Databases can also be exported through both phpMyAdmin and the command line.

Method 1: Using PhpMyAdmin

To export your database using PhpMyAdmin, then log into SPanel’s User Interface and open phpMyAdmin.

How to Import and Export a MySQL Database

Click Export on the top bar.

How to Import and Export a MySQL Database

Click on the “Custom” radio button to list all the databases on the server. Choose the export format, then select the database you intend to export.

How to Import and Export a MySQL Database

Configure the export options and click on the “Go” button to export the file to your computer.

Method 2: Using Command Line

Using phpMyAdmin places a limit on the file size you can export. The command line provides a safe and efficient way to export both small and large databases.

Here’s how to export a database using the command line.

Log in to your server remotely using SSH.

Use this command mysqldump –routines -u username -p dbname > dbexport.sql  to export the database. Replace “username” and “dbname” in the command with the username and database name of the database you want to export. 

Replace dbexport.sql with the file name and format you want to export the database to. When prompted, enter the user’s password to run the export. The database export will reside in your server in the file name and format you specified. 

Connect remotely to the server using FTP to download the file to your local computer.

Was this helpful?

What’s your goal today?

1. Find the right Managed VPS solution

If you’re looking for industry-leading speed, ease of use and reliability Try ScalaHosting with an unconditional money-back guarantee.

2. Make your website lighting fast

We guarantee to make your WordPress site load in less than 2 seconds on a managed VPS with ScalaHosting or give your money back. Fill out the form, and we’ll be in touch.

Please enter a valid name
Please enter a valid website
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

3. Streamline your clients’ hosting experience

If you’re a web studio or development agency hosting more than 30 websites, schedule a call with Vlad, our co-founder and CTO, and see how we can deliver unmatched value to both your business and your clients.


Need a custom cluster or professional advice?

Book a meeting and get a free 30-minute consultation with Vlad, co-founder & CTO of Scala Hosting, who will help you select, design and build the right solution - from a single data center cluster to a multi-region & multi-datacenter high availability cluster with hundreds of servers.

Book a free consultation

4. Learn how to grow your website in 2023

An all-star team of SEO and web influencers are sharing their secret knowledge for the first time in years. Learn about the future of SEO, Web Design best practices and the secrets to getting the foundation for your website to thrive. Watch the exclusive webinar.

An Exclusive Insiders Look Behind The SEO and Web Development Curtain


Working in the web hosting industry for over 13 years, Rado has inevitably got some insight into the industry. A digital marketer by education, Rado is always putting himself in the client's shoes, trying to see what's best for THEM first. A man of the fine detail, you can often find him spending 10+ minutes wondering over a missing comma or slightly skewed design.