Bluehost 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: Bluehost 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 Bluehost username prefix with the _ (underscore) after it and the database name.

    Knowledgebase Article 272,449 views bookmark tags: command database import line mysql phpmyadmin ssh (updated 642 days ago)


    Was this resource helpful?

    Did this resolve your issue?


    Please add any other comments or suggestions about this content:





    Recommended Help Content

    Knowledgebase Article

    Managing Databases via Command Line (SSH)

    This article will instruct you how to export a database from the command line (SSH). (updated 231 days ago)

    Knowledgebase Article

    How to import a MySQL Database using phpMyAdmin

    How do I import a backup of my database (.sql file) using phpMyAdmin? (updated 460 days ago)

    Knowledgebase Article

    MySQL Import and Export

    I need to Export or Import a MySQL database (updated 231 days ago)

    Related Help Content

    Knowledgebase Article

    Managing Your Database Using phpMyAdmin

    A repository of information on how you can manage your database by using the phpMyAdmin interface. (updated 461 days ago)

    Knowledgebase Article

    MySQL Database Restore

    How to Restore your MySQL Database? (updated 648 days ago)

    Knowledgebase Article

    Mysql connections with a dynamic (changing) IP Address using ssh/putty ect

    Users having problems connecting to mysql database using SSH and/or putty/other client. (updated 1355 days ago)

    Knowledgebase Article

    How to copy a database in phpMyAdmin

    A guide to duplicating a MySQL database using phpMyAdmin (updated 461 days ago)

    Knowledgebase Article

    Dropping columns from a database table in phpMyAdmin

    A tutorial on how to perminately delete columns from your mySQL database using phpMyAdmin (updated 460 days ago)

    Knowledgebase Article

    How to add tables to a database in phpMyAdmin

    Guidance on adding tables to your mySQL database in phpMyAdmin (updated 461 days ago)

    Knowledgebase Article

    Searching through a MySQL database in phpMyAdmin

    Step by step directions on how you can search your database using phpMyAdmin (updated 460 days ago)

    Knowledgebase Article

    MySQL Repair / Optimize Tables in phpMyAdmin

    How to repair and optimize your database using phpMyAdmin: (updated 653 days ago)