This site utilizes JavaScript to function correctly. Looks like it's disabled on your browser. Please enable it for your best experience.

For instructions on enabling JavaScript, click here

Skip to main content

Just Host Web Hosting Help

How Import Databases Using Command Line SSH

Importing Databases via Command Line (SSH)

Using SSH can be a superior way to manage the files and databases on your account. Using a simple command you can import a MySQL database into an existing database on your account. If are looking for instructions to export a database, please go to the Exporting Databases via Command Line (SSH) article. If you are looking for instructions for importing and exporting databases using phpMyAdmin, please go to the Export Databases with phpMyAdmin articles.

Note: SSH access is required for this process. Click Here for information about getting SSH access

Using Command Line (SSH) to import your MySQL database

The file must be in .sql format. It can not be compressed in a .zip or .tar.gz file.

  1. Upload the SQL file to the server via the file manager or an FTP client.
  2. If the database does not exist, please create a database, a user, and give the user full privileges to the database. Note the username and password.
  3. Log into the server through SSH
  4. Navigate to the directory where your .sql file is.
  5. Type in this command:
    mysql -p -u user_name database_name < file.sql (replace 'user_name', 'database_name', and 'file.sql' with the actual name.)
  6. You will be prompted for your database user password, and then your database will be imported.
Note: Just Host recommends using the database user with the database user's password and not the cPanel main user and password. The -p flag will cause mysql to prompt for your account's password. Do not put passwords in command line in plain text, but let the system prompt for a password. This is for your own security.

Make sure your database name and username has your Just Host username prefix (e.g. 'username_databasename'; 'username_databaseusername').
Knowledgebase Article 775,404 views bookmark tags: database mysql ssh


Was this resource helpful?

Did this resolve your issue?


Please add any other comments or suggestions about this content:





Recommended Help Content

This article will instruct you how to export a database from the command line (SSH).
Knowledgebase Article 862,151 views tags: database mysql ssh

I need to Export or Import a MySQL database
Knowledgebase Article 418,174 views tags: mysql phpmyadmin ssh

This article will explain MySQL database and user creation and deletion, and explain how to assign a user to a database.
Knowledgebase Article 873,273 views tags: creation database mysql

Related Help Content

How do I import a backup of my database (.sql file) using phpMyAdmin?
Knowledgebase Article 781,225 views tags: database mysql phpmyadmin

This article will explain how to connect your scripts to your MySQL databases.
Knowledgebase Article 236,833 views tags: database mysql scripts

Is SSH/Shell access enabled by default?
Knowledgebase Article 872,671 views tags: bash command line secure shell ssh

How to Restore your MySQL Database?
Knowledgebase Article 383,495 views tags: admin database mysql php phpmyadmin restore

How do I make my MySQL database compatible with the version you provide?
Knowledgebase Article 245,115 views tags: compatible database mysql

How do I create a MySQL backup?
Knowledgebase Article 418,413 views tags: backup database mysql

This article will explain how to change the password for a database in the event that the original password is lost.
Knowledgebase Article 263,385 views tags: database mysql password

This article will go over different application available for remote connection to your databases.
Knowledgebase Article 240,914 views tags: database mysql

** Google ad credits are only available to customers in the United States, Canada, and the United Kingdom at this time.

¹ VAT (Value Added Tax) is not included in our advertised price and will be charged separately and itemized on invoices and billing information. Standard VAT rates based on EU Member State regulations may apply. Learn more.