How do I import a .sql file via the command-line?

With SSH access for your package, you can use the following command-line instructions to import a MySQL database:
mysql -h hostname -u username -p username < databasefile.sql

The above command will connect you to your database with the -h (hostname) -u (username) -p (database name in this case) then the unzipped file < databasefile.sql

You will be now asked to enter a password for the database. Input the password and press enter.

Compressed files
In case, if the database file is zipped then you will need to unzip it first and then you can use one of the following commands:
For a .zip file you can use the unzip command:
unzip databasefile.sql.zip
mysql -h hostname -u username -p username < databasefile.sql

For a .gz file you can use the gunzip command:
gunzip databasefile.sql.gz
mysql -h hostname -u username -p username < databasefile.sql

 

There is a guide about how to connect to your package via SSH here.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How do I connect via SSH?

We recommended you to connect to your package via SSH only if you're familiar with the command...

How do I connect via SSH on an Apple Mac?

To connect using SSH on a Mac,please follow the instructions below:1. Log in to Hamro.Cloud2. Go...