To import a MySQL database via SSH, use this command:
mysql -h hostname -u username -p username < databasefile.sql
This connects to your database server using the hostname, username, and password credentials, then redirects the SQL file contents into the database. You'll be prompted to enter your database password after executing the command.
Handling Compressed Files
For .zip files:
unzip databasefile.sql.zip
mysql -h hostname -u username -p username < databasefile.sql
For .gz files:
gunzip databasefile.sql.gz
mysql -h hostname -u username -p username < databasefile.sql
Key Requirements: SSH access must be configured for your hosting package to execute these command-line operations.