HostMonster Web Hosting Help

MySQL Database Import via Command Line

Summary

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.
Note: SSH access is required for this process. Click Here for information about getting SSH access

Using 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.
  2. If the database does not exist please create one with an user. Note the username and password.
  3. Log into the server through SSH
  4. Navigate to the directory where your .sql file is.
  5. Type this this command:
    mysql -p -u username database_name < file.sql

    Note: HostMonster recomends using the database user with the database users password not the cPanel main user and password. The -p 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 has your HostMonster username prefix with the _ (underscore) after it and the database name.

    Knowledgebase Article 385,701 views bookmark tags: command database import line mysql phpmyadmin ssh (updated 1017 days ago)


    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). (updated 606 days ago)
    Knowledgebase Article 428,064 views tags: database mysql ssh

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

    I need to Export or Import a MySQL database (updated 605 days ago)
    Knowledgebase Article 216,320 views tags: mysql phpmyadmin ssh

    Related Help Content

    A repository of information on how you can manage your database by using the phpMyAdmin interface. (updated 835 days ago)
    Knowledgebase Article 144,117 views tags: commands database mysql phpmyadmin

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

    Users having problems connecting to mysql database using SSH and/or putty/other client. (updated 1731 days ago)
    Knowledgebase Article 60,216 views tags: connection ip mysql putty ssh whitelist

    A guide to duplicating a MySQL database using phpMyAdmin (updated 836 days ago)
    Knowledgebase Article 29,058 views tags: databases mysql phpmyadmin

    A tutorial on how to perminately delete columns from your mySQL database using phpMyAdmin (updated 834 days ago)
    Knowledgebase Article 35,331 views tags: Plesk cpanel databases mysql phpmyadmin

    Guidance on adding tables to your mySQL database in phpMyAdmin (updated 835 days ago)
    Knowledgebase Article 13,779 views tags: mysql phpmyadmin

    Step by step directions on how you can search your database using phpMyAdmin (updated 836 days ago)
    Knowledgebase Article 11,937 views tags: Plesk cpanel databases mysql phpmyadmin

    This article will walk you through the steps to copying and renaming a database with phpMyAdmin. (updated 3 days ago)
    Knowledgebase Article 15,859 views tags: database phpmyadmin