Question: I cannot find a solution to this particular demand.
I have a mysql dump on my computer and I want to import it in a web server using SSH. 
How do I do that ? 
Can I add the ssh connection to the mysql command ?

Edit :
I did it with SCP

```
scp -r -p /Users/me/files/dump.sql user@server:/var/www/private
mysql -hxxx -uxxx -pxxx dbname < dump.sql

```

Answer: 
As the comment above says, the simplest solution is to scp the whole dump file up to your server, and then restore it normally. But that means you have to have enough free disk space to store the dump file on your webserver. You might not.

An alternative is to set up a temporary ssh tunnel to your web server. Read <https://www.howtogeek.com/168145/how-to-use-ssh-tunneling/> for full instructions, but it would look something like this:

```
nohup ssh -L 8001:localhost:3306 -N user@webserver >/dev/null 2>&1 &

```

This means when I connect to port 8001 on my local host (you can pick any unused port number here), it's really being given a detour through the ssh tunnel to the webserver, where it connects to port 3306, the MySQL default port.

In the example above, your `user@webserver` is just a placeholder, so you must replace it with your username and your webserver hostname.

Then restore your dump file as if you're restoring to a hypothetical MySQL instance running on port 8001 on the local host. This way you don't have to scp the dump file up to your webserver. It will be streamed up to the webserver via the ssh tunnel, and then applied to your database directly.

```
pv -pert mydumpfile.sql | mysql -h 127.0.0.1 -P 8001

```

You have to specify 127.0.0.1, because the MySQL client uses "localhost" as a special name for a non-network connection.

I like to use `pv` to read the dumpfile, because it outputs a progress bar.
You can try this solution for your problem : 

**Login using SSH details :-**

```
SSH Host name : test.com
SSH User : root
SSH Password : 123456

```

**Connect SSH :-**

```
ssh root@test.com
enter password : 123456

```

**Login MySQL :-**

```
mysql -u [MySQL User] -p
Enter Password :- MySQL Password

```

**Used following command for Import databases :-**

```
show databases; // List of Databased
use databasedname; // Enter You databased name to Import databased
source path;  // Set path for Import databased for ex : /home/databased/import.sql 

```

I hope this will helps you.