I haven't tried exactly that, but I can log in to the database via ssh and the mysql command using the same credentials from my core/config/config.inc.php.
source path/to/file.sql;
If you can connect to the server and use the database, then you could try
source path/to/file.sql;