Just Host Web Hosting Help

MySQL Import and Export (.sql file) via SSH

Summary

This tutorial outlines the steps for importing and exporting MySQL databases via command line (SSH). Click Here for information about getting SSH access.

Export A MySQL Database

This example shows you how to export a database. It is a good idea to export your data often as a backup.
  1. Using SSH, execute the following command:
            mysqldump -p -u username database_name > dbname.sql 
            
  2. You will be prompted for a password, type in the password for the username and press Enter. Replace username, password and database_name with your MySQL username, password and database name.

The file dbname.sql now holds a backup of your database and is ready for download to your computer.

Import A MySQL Database

The file must be in .sql format. It can not be compressed in a .zip or .tar.gz file.
  1. Start by uploading the .sql file onto the Just Host server
  2. If you haven't already done so, create the MySQL database via the cpanel. Click Here for further instructions
  3. Using SSH, navigate to the directory where your .sql file is.
  4. Next run this command:
     mysql -p -u username database_name < file.sql 

    Note: The -p will prompt for your account's password.

    Note: username is the user with rights to the database. If you are unsure what the username is you can use the same username and password used to sign into SSH.

    Note: Make sure your database name has your Just Host username prefix with the _ (underscore) after it and the database name.

Knowledgebase Article 254,941 views bookmark tags: database mysql (updated 266 days ago)


Was this resource helpful?

Did this resolve your issue?


Please add any other comments or suggestions about this content:





Recommended Help Content

How do I import a database using command line? (SSH) (updated 397 days ago)
Knowledgebase Article 186,517 views tags: command database import line mysql phpmyadmin ssh

I need to Export or Import a MySQL database (updated 1396 days ago)
Knowledgebase Article 120,126 views tags: database import mysql php transfer

An exported .sql file shows as a different size than the reported size in cPanel (updated 802 days ago)
Knowledgebase Article 15,778 views tags: backup database dump export mysql mysqldump size sql

Related Help Content

How do I import a backup of my database (.sql file) using phpMyAdmin? (updated 215 days ago)
Knowledgebase Article 67,077 views tags: database mysql phpmyadmin

How to export your database in phpMyAdmin.. (updated 216 days ago)
Knowledgebase Article 44,320 views tags: database export myphpadmin

If you have a WordPress blog hosted on wordpress.com, you can easily export it and import it to WordPress that is installed on your hosting account with justhost. Login to the WordPress D (updated 650 days ago)
Getting Started Article 115,520 views tags: blog export file import wordpress

How do I make my MySQL database compatible with the version you provide? (updated 1412 days ago)
Knowledgebase Article 47,301 views tags: database mysql

How to Restore your MySQL Database? (updated 404 days ago)
Knowledgebase Article 64,689 views tags: admin database mysql php phpmyadmin restore

How do I create a MySQL backup? (updated 92 days ago)
Knowledgebase Article 83,359 views tags: backup database mysql

Site Backup & Restore tool displays unexpected dates. (updated 802 days ago)
Knowledgebase Article 14,221 views tags: backup database dump mysql restore sql

This article will explain MySQL database and user creation and deletion, and explain how to assign a user to a database. (updated 203 days ago)
Knowledgebase Article 227,655 views tags: creation database mysql