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

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

If you've set up SSH access for a package then you can run the following command-line instructions to import a MySQL database:

mysql -h hostname -u username -p username < databasefile.sql

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

You will then be prompted to enter a password for the database. Input the password and press enter.

Compressed files

If the database file is zipped then you will need to unzip it first, 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
    • Related Articles

    • How do I import a .sql file via phpMyAdmin?

      You can use phpMyAdmin to import an .SQL file with your database information. To do this: Log in to your database via phpMyAdmin (Here > Manage Hosting > [select package] > phpMyAdmin)  Choose the database you want to import your .SQL file to from ...
    • How do I import a .sql file via phpMyAdmin?

      You can use phpMyAdmin to import an .SQL file with your database information. To do this: Log in to your database via phpMyAdmin (HERE > Manage Hosting > [select package] > phpMyAdmin)  Choose the database you want to import your .SQL file to from ...
    • How do I import a .sql file via phpMyAdmin?

      You can use phpMyAdmin to import an .SQL file with your database information. To do this: Log in to your database via phpMyAdmin (Login HERE > Manage Hosting > [select package] > phpMyAdmin)  Choose the database you want to import your .SQL file to ...
    • How do I import a .sql file via phpMyAdmin?

      You can use phpMyAdmin to import an .SQL file with your database information. To do this: Log in to your database via phpMyAdmin (Login HERE > Manage Hosting > [select package] > phpMyAdmin)  Choose the database you want to import your .SQL file to ...
    • Can I import contacts into Webmail?

      Yes, you can import a contact list from a previous mail client into VISYOO webmail. To do so:  Log in to Webmail for the mailbox. Head to the Address Book. Select the Import icon from the top-left. You can then select either a .CSV file or a vCard ...