You want to perform a large MySQL database import, and you need a reliable way to read and write data across network connections.
Netcat is a useful tool for reading doing just that. You can utilize it to work directly, or over an SSH tunnel.
In the case where you already have a database and you want to put it on a particular host in a specific database, follow these steps:
netcat -l 48151 | mysql -u [username] --password=[password] targetdb
Where [username]
is your MySQL username, and [password]
is the username's password.
mysqldump
command into a Netcat sender that's pointed to the port on the target host that you configured in the previous step:
mysqldump -u [username] --password=[password] sourcedb | netcat targethost 48151
After the the target host command finishes you should have a complete database dump.
You can read general information about SSH tunnels in the article SSH tunneling for server-side applications. The following instructions are directly suited to Netcat.
If the target host is behind a firewall, you may need to tunnel the Netcat connection through it using SSH port forwarding. To do this:
Note
This example assumes that your Netcat listener is using port 48151 as in the preceding example.
ssh targethost -L 48151:localhost:48151 -f sleep 600m
netcat -l 48151 | mysql -u [username] --password=[password] targetdb
Where [username]
is your MySQL username, and [password]
is the username's password.
mysqldump -u [username] --password=[password] sourcedb | netcat localhost 48151
If this content did not answer your questions, try searching or contacting our support team for further assistance.
Wed Oct 22 2025 08:59:29 GMT+0000 (Coordinated Universal Time)