MySQL Database Import via Command Line

How do I import a database using command line? (SSH)

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

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

  • 17 Users Found This Useful
Was this answer helpful?

Related Articles

MySQL Database Creation

Problem: How do I create an empty MySQL Database? Solution: Databases offer a method for...

Remote Database Connection Setup

How do I remotely connect using a database management software? Databases in cPanel can be...

MySQL Import and Export (.sql file) via SSH

Problem: How to import and export a MySQL Database from the command line. Solution: MySQL...

MySQL Import and Export (.sql file) via PhpMyAdmin

Problem: I need to Export or Import a MySQL database Solution: Note: PhpMyAdmin can only...

Connecting to your MySQL DB from Dream Weaver

Problem: How can I connect to our MySQL database from Dream Weaver? Solution: Log into your...