How to Import MySQL Database via SSH

Follow the steps below on how to import your MySQL database to phpMyAdmin via SSH. This method is applicable if you can upload the .SQL file to your hosting account.  

Note: SSH connections are only allowed in Vodien Virtual Private Server and Dedicated Server plans. 

Step 1. Upload your .SQL file via FTP or upload it via File Manager and take note of its file path as you will use this in Step 3 and Step 4.  

Tip: The directory or file path is located on the upper right side of File Manager page and on the remote side panel of the FTP. See images below for reference.

File Path in cPanel File Manager

FTP Remote Site File Path

Step 2. Connect to SSH via Windows or connect to SSH via Mac 

Step 3. Enter the code below to access the directory where your .SQL file is located. Replace directory with the file path obtained from Step 1. Then, click the Enter key of your computer.  

cd directory/

Step 4. Enter the command below to import the database. Replace databaseusername, databasename, and directory/filetoimport.sql with the database username, database name, and the file path respectively. If the database does not exist yet, create a new MySQL Database. 

mysql -h localhost -u databaseusername -p databasename < directory/filetoimport.sql

Step 5. Enter the database password on the command line. Whatever you type in here does not appear, but it captures anything you paste or enter.  

Enter Database Password to Import

Once successful, you can check your phpMyAdmin to confirm.  

Feel free to contact our Singapore or Australia Support Team if you have further questions. 

(Visited 293 times, 1 visits today)

Was this article helpful?

Related Articles